Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/clusterproxy/cluster_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
clusterv1 "sigs.k8s.io/cluster-api/api/core/v1beta2"
"sigs.k8s.io/cluster-api/util/annotations"
"sigs.k8s.io/controller-runtime/pkg/client"

libsveltosv1beta1 "github.com/projectsveltos/libsveltos/api/v1beta1"
Expand Down Expand Up @@ -103,12 +104,7 @@ func isCAPIClusterPaused(ctx context.Context, c client.Client,
return false, err
}

paused := false
if cluster.Spec.Paused != nil {
paused = *cluster.Spec.Paused
}

return paused, nil
return annotations.IsPaused(cluster, cluster), nil
}

// isSveltosClusterPaused returns true if Cluster is paused
Expand Down
16 changes: 16 additions & 0 deletions lib/clusterproxy/cluster_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ var _ = Describe("Cluster utils", func() {
Expect(paused).To(BeFalse())
})

It("IsClusterPaused returns true for a CAPI Cluster with the paused annotation and Spec.Paused set to false", func() {
paused := false
cluster.Spec.Paused = &paused
cluster.Annotations = map[string]string{clusterv1.PausedAnnotation: ""}
initObjects := []client.Object{
cluster,
}

c := fake.NewClientBuilder().WithScheme(scheme).WithObjects(initObjects...).Build()

isPaused, err := clusterproxy.IsClusterPaused(context.TODO(), c, cluster.Namespace,
cluster.Name, libsveltosv1beta1.ClusterTypeCapi)
Expect(err).To(BeNil())
Expect(isPaused).To(BeTrue())
})

It("GetSecretData returns kubeconfig data", func() {
randomData := []byte(randomString())
sveltosSecret := corev1.Secret{
Expand Down
Loading