Skip to content

Commit 69b2fe9

Browse files
committed
Use pointer to a bool instead of bool
1 parent 3d1a8c3 commit 69b2fe9

File tree

6 files changed

+12
-6
lines changed

6 files changed

+12
-6
lines changed

api/v1beta3/cloudstackcluster_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type CloudStackClusterSpec struct {
3737

3838
// SyncWithACS determines if an externalManaged CKS cluster should be created on ACS.
3939
// +optional
40-
SyncWithACS bool `json:"syncWithACS,omitempty"`
40+
SyncWithACS *bool `json:"syncWithACS,omitempty"`
4141
}
4242

4343
// The status of the CloudStackCluster object.

api/v1beta3/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controllers/cks_cluster_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (reconciler *CksClusterReconciler) Reconcile(ctx context.Context, req ctrl.
6969

7070
// Reconcile actually reconciles the CloudStackCluster.
7171
func (r *CksClusterReconciliationRunner) Reconcile() (res ctrl.Result, reterr error) {
72-
if !r.CSCluster.Spec.SyncWithACS || len(r.FailureDomains.Items) == 0 {
72+
if r.CSCluster.Spec.SyncWithACS == nil || !*r.CSCluster.Spec.SyncWithACS || len(r.FailureDomains.Items) == 0 {
7373
return ctrl.Result{}, nil
7474
}
7575
// Prevent premature deletion.

controllers/cks_machine_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (reconciler *CksMachineReconciler) Reconcile(ctx context.Context, req ctrl.
6969

7070
// Reconcile actually reconciles the CloudStackMachine.
7171
func (r *CksMachineReconciliationRunner) Reconcile() (res ctrl.Result, reterr error) {
72-
if !r.CSCluster.Spec.SyncWithACS {
72+
if r.CSCluster.Spec.SyncWithACS == nil || !*r.CSCluster.Spec.SyncWithACS {
7373
return ctrl.Result{}, nil
7474
}
7575
if r.CSCluster.Status.CloudStackClusterID == "" {

controllers/cks_machine_controller_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
. "github.com/onsi/ginkgo/v2"
2222
. "github.com/onsi/gomega"
2323
"k8s.io/apimachinery/pkg/api/errors"
24+
"k8s.io/utils/pointer"
2425
infrav1 "sigs.k8s.io/cluster-api-provider-cloudstack/api/v1beta3"
2526
"sigs.k8s.io/cluster-api-provider-cloudstack/controllers"
2627
dummies "sigs.k8s.io/cluster-api-provider-cloudstack/test/dummies/v1beta3"
@@ -33,7 +34,7 @@ var _ = Describe("CksCloudStackMachineReconciler", func() {
3334
Context("With machine controller running.", func() {
3435
BeforeEach(func() {
3536
dummies.SetDummyVars()
36-
dummies.CSCluster.Spec.SyncWithACS = true
37+
dummies.CSCluster.Spec.SyncWithACS = pointer.Bool(true)
3738
dummies.CSCluster.Spec.FailureDomains = dummies.CSCluster.Spec.FailureDomains[:1]
3839
dummies.CSCluster.Spec.FailureDomains[0].Name = dummies.CSFailureDomain1.Spec.Name
3940
dummies.CSCluster.Status.CloudStackClusterID = "cluster-id-123"

test/dummies/v1beta3/vars.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ var ( // Declare exported dummy vars.
8080
LBRuleID string
8181
PublicIPID string
8282
EndPointHost string
83-
SyncWithACS bool
83+
SyncWithACS *bool
8484
EndPointPort int32
8585
CSConf *simpleyaml.Yaml
8686
DiskOffering infrav1.CloudStackResourceDiskOffering
@@ -274,7 +274,7 @@ func SetDummyCAPCClusterVars() {
274274
CSClusterKind = "CloudStackCluster"
275275
ClusterName = "test-cluster"
276276
EndPointHost = "EndpointHost"
277-
SyncWithACS = true
277+
SyncWithACS := pointer.Bool(true)
278278
EndPointPort = int32(5309)
279279
PublicIPID = "FakePublicIPID"
280280
ClusterNameSpace = "default"

0 commit comments

Comments
 (0)