From d3097356ae29b5274b216ff3151ed189e625444b Mon Sep 17 00:00:00 2001 From: Miles Garnsey <11435896+Miles-Garnsey@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:26:44 +0900 Subject: [PATCH] Make HttpManagement.Enabled a pointer. (#1091) --- apis/reaper/v1alpha1/reaper_types.go | 2 +- apis/reaper/v1alpha1/zz_generated.deepcopy.go | 7 ++++++- pkg/reaper/deployment.go | 2 +- pkg/reaper/deployment_test.go | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/apis/reaper/v1alpha1/reaper_types.go b/apis/reaper/v1alpha1/reaper_types.go index 256a4ace7..6d5decd6f 100644 --- a/apis/reaper/v1alpha1/reaper_types.go +++ b/apis/reaper/v1alpha1/reaper_types.go @@ -378,7 +378,7 @@ type HttpManagement struct { // When enabled, HTTP will be used instead of JMX for management connectivity between Cassandra // and Reaper. In future, this will be true by default // +kubebuilder:default=false - Enabled bool `json:"enabled"` + Enabled *bool `json:"enabled"` } // +kubebuilder:object:root=true diff --git a/apis/reaper/v1alpha1/zz_generated.deepcopy.go b/apis/reaper/v1alpha1/zz_generated.deepcopy.go index aefcba36e..a94a532c5 100644 --- a/apis/reaper/v1alpha1/zz_generated.deepcopy.go +++ b/apis/reaper/v1alpha1/zz_generated.deepcopy.go @@ -73,6 +73,11 @@ func (in *CassandraDatacenterRef) DeepCopy() *CassandraDatacenterRef { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HttpManagement) DeepCopyInto(out *HttpManagement) { *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HttpManagement. @@ -302,7 +307,7 @@ func (in *ReaperTemplate) DeepCopyInto(out *ReaperTemplate) { *out = new(meta.ResourceMeta) (*in).DeepCopyInto(*out) } - out.HttpManagement = in.HttpManagement + in.HttpManagement.DeepCopyInto(&out.HttpManagement) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReaperTemplate. diff --git a/pkg/reaper/deployment.go b/pkg/reaper/deployment.go index 266813bb2..fada5053b 100644 --- a/pkg/reaper/deployment.go +++ b/pkg/reaper/deployment.go @@ -152,7 +152,7 @@ func NewDeployment(reaper *api.Reaper, dc *cassdcapi.CassandraDatacenter, keysto Value: fmt.Sprintf("%d", reaper.Spec.HeapSize.Value()), }) } - if reaper.Spec.HttpManagement.Enabled { + if reaper.Spec.HttpManagement.Enabled != nil && *reaper.Spec.HttpManagement.Enabled { envVars = append(envVars, corev1.EnvVar{ Name: "REAPER_HTTP_MANAGEMENT_ENABLE", Value: "true", diff --git a/pkg/reaper/deployment_test.go b/pkg/reaper/deployment_test.go index 4cb5b3a13..29a215211 100644 --- a/pkg/reaper/deployment_test.go +++ b/pkg/reaper/deployment_test.go @@ -28,7 +28,7 @@ func TestNewDeployment(t *testing.T) { reaper.Spec.AutoScheduling = reaperapi.AutoScheduling{Enabled: false} reaper.Spec.ServiceAccountName = "reaper" reaper.Spec.DatacenterAvailability = DatacenterAvailabilityAll - reaper.Spec.HttpManagement.Enabled = true + reaper.Spec.HttpManagement.Enabled = pointer.Bool(true) reaper.Spec.ClientEncryptionStores = &encryption.Stores{ KeystoreSecretRef: &encryption.SecretKeySelector{LocalObjectReference: corev1.LocalObjectReference{ Name: "keystore-secret",