From e49db2f3ef1790c4a45179bc8ec6234dd9ff7a8a Mon Sep 17 00:00:00 2001 From: Miles Garnsey Date: Mon, 13 May 2024 19:08:16 +1000 Subject: [PATCH] Very annoying deprecation errors. --- apis/stargate/v1alpha1/stargate_types_test.go | 13 +-- .../v1alpha1/telemetry_methods_test.go | 44 +++++----- controllers/k8ssandra/auth_test.go | 10 +-- .../k8ssandra/cassandra_metrics_agent_test.go | 6 +- .../cassandra_telemetry_reconciler_test.go | 11 ++- .../k8ssandracluster_controller_test.go | 12 +-- controllers/k8ssandra/vector_test.go | 8 +- controllers/reaper/reaper_controller.go | 6 +- .../reaper_telemetry_reconciler_test.go | 5 +- controllers/reaper/vector_test.go | 4 +- .../stargate/stargate_controller_test.go | 9 +- .../stargate_telemetry_reconciler_test.go | 5 +- controllers/stargate/vector_test.go | 4 +- pkg/cassandra/config_premarshal_test.go | 84 +++++++++---------- pkg/cassandra/config_test.go | 11 ++- pkg/cassandra/datacenter_test.go | 12 +-- pkg/goalesce/utils_test.go | 16 ++-- pkg/medusa/reconcile.go | 8 +- pkg/reaper/deployment_test.go | 4 +- pkg/reaper/vector_test.go | 4 +- pkg/stargate/deployments_test.go | 9 +- pkg/stargate/vector_test.go | 4 +- .../cassandra_metrics_filters_test.go | 6 +- pkg/telemetry/validation_test.go | 10 +-- pkg/telemetry/vector_test.go | 16 ++-- test/e2e/auth_test.go | 4 +- test/e2e/reaper_test.go | 6 +- test/e2e/suite_test.go | 12 +-- test/framework/e2e_framework.go | 4 +- test/framework/framework.go | 10 +-- 30 files changed, 176 insertions(+), 181 deletions(-) diff --git a/apis/stargate/v1alpha1/stargate_types_test.go b/apis/stargate/v1alpha1/stargate_types_test.go index a85d323ed..c471dbb4b 100644 --- a/apis/stargate/v1alpha1/stargate_types_test.go +++ b/apis/stargate/v1alpha1/stargate_types_test.go @@ -1,13 +1,14 @@ package v1alpha1 import ( + "testing" + "github.com/k8ssandra/k8ssandra-operator/pkg/images" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/pointer" - "testing" + "k8s.io/utils/ptr" ) var ( @@ -228,7 +229,7 @@ func testStargateDatacenterTemplateMerge(t *testing.T) { Repository: "repo2", Name: "img2", }, - ServiceAccount: pointer.String("sa2"), + ServiceAccount: ptr.To("sa2"), HeapSize: &quantity256Mi, NodeSelector: map[string]string{"k2": "v2a", "k3": "v3"}, Tolerations: []corev1.Toleration{{Key: "k2", Value: "v2"}}, @@ -270,7 +271,7 @@ func testStargateDatacenterTemplateMerge(t *testing.T) { Name: "img1", }, HeapSize: &quantity512Mi, - ServiceAccount: pointer.String("sa2"), + ServiceAccount: ptr.To("sa2"), // map will be merged NodeSelector: map[string]string{"k1": "v1", "k2": "v2", "k3": "v3"}, // slice will not be merged, slice1 will be kept intact @@ -384,7 +385,7 @@ func testStargateRackTemplateMerge(t *testing.T) { Repository: "repo2", Name: "img2", }, - ServiceAccount: pointer.String("sa2"), + ServiceAccount: ptr.To("sa2"), HeapSize: &quantity256Mi, NodeSelector: map[string]string{"k2": "v2a", "k3": "v3"}, Tolerations: []corev1.Toleration{{Key: "k2", Value: "v2"}}, @@ -424,7 +425,7 @@ func testStargateRackTemplateMerge(t *testing.T) { Name: "img1", }, HeapSize: &quantity512Mi, - ServiceAccount: pointer.String("sa2"), + ServiceAccount: ptr.To("sa2"), // map will be merged NodeSelector: map[string]string{"k1": "v1", "k2": "v2", "k3": "v3"}, // slice will not be merged, slice1 will be kept intact diff --git a/apis/telemetry/v1alpha1/telemetry_methods_test.go b/apis/telemetry/v1alpha1/telemetry_methods_test.go index 021c62b1e..402a07a82 100644 --- a/apis/telemetry/v1alpha1/telemetry_methods_test.go +++ b/apis/telemetry/v1alpha1/telemetry_methods_test.go @@ -1,10 +1,10 @@ package v1alpha1 import ( - "k8s.io/utils/pointer" "testing" "github.com/stretchr/testify/assert" + "k8s.io/utils/ptr" ) func TestTelemetrySpec_IsPrometheusEnabled(t *testing.T) { @@ -34,7 +34,7 @@ func TestTelemetrySpec_IsPrometheusEnabled(t *testing.T) { name: "false", in: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(false), + Enabled: ptr.To(false), }, }, want: false, @@ -43,7 +43,7 @@ func TestTelemetrySpec_IsPrometheusEnabled(t *testing.T) { name: "true", in: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, }, want: true, @@ -79,7 +79,7 @@ func TestTelemetrySpec_MergeWith(t *testing.T) { name: "non empty cluster, nil dc", cluster: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{ "key1": "value1", }, @@ -88,7 +88,7 @@ func TestTelemetrySpec_MergeWith(t *testing.T) { dc: nil, want: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{ "key1": "value1", }, @@ -100,7 +100,7 @@ func TestTelemetrySpec_MergeWith(t *testing.T) { cluster: nil, dc: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{ "key1": "value1", }, @@ -108,7 +108,7 @@ func TestTelemetrySpec_MergeWith(t *testing.T) { }, want: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{ "key1": "value1", }, @@ -119,7 +119,7 @@ func TestTelemetrySpec_MergeWith(t *testing.T) { name: "non empty cluster, non empty dc", cluster: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{ "key1": "cluster", "key2": "cluster", @@ -128,7 +128,7 @@ func TestTelemetrySpec_MergeWith(t *testing.T) { }, dc: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(false), + Enabled: ptr.To(false), CommonLabels: map[string]string{ "key1": "dc", "key3": "dc", @@ -137,7 +137,7 @@ func TestTelemetrySpec_MergeWith(t *testing.T) { }, want: &TelemetrySpec{ Prometheus: &PrometheusTelemetrySpec{ - Enabled: pointer.Bool(false), + Enabled: ptr.To(false), CommonLabels: map[string]string{ "key1": "dc", "key2": "cluster", @@ -172,49 +172,49 @@ func TestTelemetrySpec_MergeEnabled(t *testing.T) { { name: "receiver enabled nil, parent enabled false", in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: nil}}, - parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(false)}}, + parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(false)}}, want: false, }, { name: "receiver enabled nil, parent enabled true", in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: nil}}, - parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(true)}}, + parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(true)}}, want: true, }, { name: "receiver enabled false, parent enabled nil", - in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(false)}}, + in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(false)}}, parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: nil}}, want: false, }, { name: "receiver enabled false, parent enabled false", - in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(false)}}, - parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(false)}}, + in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(false)}}, + parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(false)}}, want: false, }, { name: "receiver enabled false, parent enabled true", - in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(false)}}, - parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(true)}}, + in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(false)}}, + parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(true)}}, want: false, }, { name: "receiver enabled true, parent enabled nil", - in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(true)}}, + in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(true)}}, parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: nil}}, want: true, }, { name: "receiver enabled true, parent enabled false", - in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(true)}}, - parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(false)}}, + in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(true)}}, + parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(false)}}, want: true, }, { name: "receiver enabled true, parent enabled true", - in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(true)}}, - parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: pointer.Bool(true)}}, + in: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(true)}}, + parent: &TelemetrySpec{Prometheus: &PrometheusTelemetrySpec{Enabled: ptr.To(true)}}, want: true, }, } diff --git a/controllers/k8ssandra/auth_test.go b/controllers/k8ssandra/auth_test.go index e225a3431..f3a299934 100644 --- a/controllers/k8ssandra/auth_test.go +++ b/controllers/k8ssandra/auth_test.go @@ -18,7 +18,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -31,7 +31,7 @@ func createSingleDcClusterNoAuth(t *testing.T, ctx context.Context, f *framework Name: "cluster1", }, Spec: api.K8ssandraClusterSpec{ - Auth: pointer.Bool(false), + Auth: ptr.To(false), Cassandra: &api.CassandraClusterTemplate{ Datacenters: []api.CassandraDatacenterTemplate{{ Meta: api.EmbeddedObjectMeta{Name: "dc1"}, @@ -141,7 +141,7 @@ func createSingleDcClusterAuth(t *testing.T, ctx context.Context, f *framework.F Name: "cluster1", }, Spec: api.K8ssandraClusterSpec{ - Auth: pointer.Bool(true), + Auth: ptr.To(true), Cassandra: &api.CassandraClusterTemplate{ Datacenters: []api.CassandraDatacenterTemplate{{ Meta: api.EmbeddedObjectMeta{Name: "dc1"}, @@ -255,7 +255,7 @@ func createSingleDcClusterAuthExternalSecrets(t *testing.T, ctx context.Context, Name: "cluster1", }, Spec: api.K8ssandraClusterSpec{ - Auth: pointer.Bool(true), + Auth: ptr.To(true), Cassandra: &api.CassandraClusterTemplate{ Datacenters: []api.CassandraDatacenterTemplate{{ Meta: api.EmbeddedObjectMeta{Name: "dc1"}, @@ -383,7 +383,7 @@ func createSingleDcClusterExternalInternode(t *testing.T, ctx context.Context, f Name: "cluster1", }, Spec: api.K8ssandraClusterSpec{ - Auth: pointer.Bool(true), + Auth: ptr.To(true), Cassandra: &api.CassandraClusterTemplate{ Datacenters: []api.CassandraDatacenterTemplate{{ Meta: api.EmbeddedObjectMeta{Name: "dc1"}, diff --git a/controllers/k8ssandra/cassandra_metrics_agent_test.go b/controllers/k8ssandra/cassandra_metrics_agent_test.go index ddb1fbf48..c56d017d9 100644 --- a/controllers/k8ssandra/cassandra_metrics_agent_test.go +++ b/controllers/k8ssandra/cassandra_metrics_agent_test.go @@ -14,7 +14,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -33,7 +33,7 @@ func createSingleDcClusterWithMetricsAgent(t *testing.T, ctx context.Context, f DatacenterOptions: api.DatacenterOptions{ Telemetry: &telemetryapi.TelemetrySpec{ Vector: &telemetryapi.VectorSpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, }, }, @@ -52,7 +52,7 @@ func createSingleDcClusterWithMetricsAgent(t *testing.T, ctx context.Context, f }, }, PodSecurityContext: &corev1.PodSecurityContext{ - RunAsUser: pointer.Int64(999), + RunAsUser: ptr.To[int64](999), }, ManagementApiAuth: &cassdcapi.ManagementApiAuthConfig{ Insecure: &cassdcapi.ManagementApiAuthInsecureConfig{}, diff --git a/controllers/k8ssandra/cassandra_telemetry_reconciler_test.go b/controllers/k8ssandra/cassandra_telemetry_reconciler_test.go index f5dc3a90a..94ee395ca 100644 --- a/controllers/k8ssandra/cassandra_telemetry_reconciler_test.go +++ b/controllers/k8ssandra/cassandra_telemetry_reconciler_test.go @@ -5,8 +5,6 @@ package k8ssandra import ( "context" - "k8s.io/utils/pointer" - "testing" testlogr "github.com/go-logr/logr/testing" @@ -17,6 +15,7 @@ import ( "github.com/k8ssandra/k8ssandra-operator/pkg/test" promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "github.com/stretchr/testify/assert" ) @@ -53,7 +52,7 @@ func Test_reconcileCassandraDCTelemetry_TracksNamespaces(t *testing.T) { DatacenterOptions: k8ssandraapi.DatacenterOptions{ Telemetry: &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{"test-label": "test"}, }, }, @@ -81,7 +80,7 @@ func Test_mergeTelemetrySpecs(t *testing.T) { kc.Spec.Cassandra.Telemetry = &telemetryapi.TelemetrySpec{ Mcac: &telemetryapi.McacTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, } @@ -94,11 +93,11 @@ func Test_mergeTelemetrySpecs(t *testing.T) { DatacenterOptions: k8ssandraapi.DatacenterOptions{ Telemetry: &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{"test-label": "test"}, }, Mcac: &telemetryapi.McacTelemetrySpec{ - Enabled: pointer.Bool(false), + Enabled: ptr.To(false), }, }, }, diff --git a/controllers/k8ssandra/k8ssandracluster_controller_test.go b/controllers/k8ssandra/k8ssandracluster_controller_test.go index 2167bb938..fdf92e5ca 100644 --- a/controllers/k8ssandra/k8ssandracluster_controller_test.go +++ b/controllers/k8ssandra/k8ssandracluster_controller_test.go @@ -17,7 +17,7 @@ import ( "github.com/k8ssandra/k8ssandra-operator/pkg/utils" promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" cassdcapi "github.com/k8ssandra/cass-operator/apis/cassandra/v1beta1" api "github.com/k8ssandra/k8ssandra-operator/apis/k8ssandra/v1alpha1" @@ -151,7 +151,7 @@ func createSingleDcCluster(t *testing.T, ctx context.Context, f *framework.Frame }, }, PodSecurityContext: &corev1.PodSecurityContext{ - RunAsUser: pointer.Int64(999), + RunAsUser: ptr.To[int64](999), }, ManagementApiAuth: &cassdcapi.ManagementApiAuthConfig{ Insecure: &cassdcapi.ManagementApiAuthInsecureConfig{}, @@ -276,7 +276,7 @@ func createSingleDcCluster(t *testing.T, ctx context.Context, f *framework.Frame kcPatch := client.MergeFrom(kc.DeepCopy()) kc.Spec.Cassandra.Datacenters[0].DatacenterOptions.Telemetry = &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, } if err := f.Patch(ctx, kc, kcPatch, kcKey); err != nil { @@ -643,7 +643,7 @@ func applyClusterTemplateAndDatacenterTemplateConfigs(t *testing.T, ctx context. }, }, Networking: &api.NetworkingConfig{ - HostNetwork: pointer.Bool(true), + HostNetwork: ptr.To(true), }, CassandraConfig: &api.CassandraConfig{ CassandraYaml: unstructured.Unstructured{ @@ -684,7 +684,7 @@ func applyClusterTemplateAndDatacenterTemplateConfigs(t *testing.T, ctx context. }, }, Networking: &api.NetworkingConfig{ - HostNetwork: pointer.Bool(false), + HostNetwork: ptr.To(false), }, CassandraConfig: &api.CassandraConfig{ CassandraYaml: unstructured.Unstructured{ @@ -696,7 +696,7 @@ func applyClusterTemplateAndDatacenterTemplateConfigs(t *testing.T, ctx context. }, }, CDC: &cassdcapi.CDCConfiguration{ - PulsarServiceUrl: pointer.String("pulsar://test-url"), + PulsarServiceUrl: ptr.To("pulsar://test-url"), }, }, }, diff --git a/controllers/k8ssandra/vector_test.go b/controllers/k8ssandra/vector_test.go index 45c1f5f1b..9f2a77874 100644 --- a/controllers/k8ssandra/vector_test.go +++ b/controllers/k8ssandra/vector_test.go @@ -14,7 +14,7 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -33,7 +33,7 @@ func createSingleDcClusterWithVector(t *testing.T, ctx context.Context, f *frame DatacenterOptions: api.DatacenterOptions{ Telemetry: &telemetryapi.TelemetrySpec{ Vector: &telemetryapi.VectorSpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, }, }, @@ -52,7 +52,7 @@ func createSingleDcClusterWithVector(t *testing.T, ctx context.Context, f *frame }, }, PodSecurityContext: &corev1.PodSecurityContext{ - RunAsUser: pointer.Int64(999), + RunAsUser: ptr.To[int64](999), }, ManagementApiAuth: &cassdcapi.ManagementApiAuthConfig{ Insecure: &cassdcapi.ManagementApiAuthInsecureConfig{}, @@ -139,7 +139,7 @@ func createSingleDcClusterWithVector(t *testing.T, ctx context.Context, f *frame kcPatch := client.MergeFrom(kc.DeepCopy()) kc.Spec.Cassandra.Datacenters[0].DatacenterOptions.Telemetry = &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, } if err := f.Patch(ctx, kc, kcPatch, kcKey); err != nil { diff --git a/controllers/reaper/reaper_controller.go b/controllers/reaper/reaper_controller.go index cd3df5fa8..2ff49f715 100644 --- a/controllers/reaper/reaper_controller.go +++ b/controllers/reaper/reaper_controller.go @@ -33,7 +33,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -174,13 +174,13 @@ func (r *ReaperReconciler) reconcileDeployment( if password, err := cassandra.ReadEncryptionStorePassword(ctx, actualReaper.Namespace, r.Client, actualReaper.Spec.ClientEncryptionStores, encryption.StoreNameKeystore); err != nil { return ctrl.Result{RequeueAfter: r.DefaultDelay}, err } else { - keystorePassword = pointer.String(password) + keystorePassword = ptr.To(password) } if password, err := cassandra.ReadEncryptionStorePassword(ctx, actualReaper.Namespace, r.Client, actualReaper.Spec.ClientEncryptionStores, encryption.StoreNameTruststore); err != nil { return ctrl.Result{RequeueAfter: r.DefaultDelay}, err } else { - truststorePassword = pointer.String(password) + truststorePassword = ptr.To(password) } } diff --git a/controllers/reaper/reaper_telemetry_reconciler_test.go b/controllers/reaper/reaper_telemetry_reconciler_test.go index 0e20536e1..0213c4ad8 100644 --- a/controllers/reaper/reaper_telemetry_reconciler_test.go +++ b/controllers/reaper/reaper_telemetry_reconciler_test.go @@ -6,8 +6,6 @@ import ( "context" "testing" - "k8s.io/utils/pointer" - k8ssandraapi "github.com/k8ssandra/k8ssandra-operator/apis/k8ssandra/v1alpha1" testlogr "github.com/go-logr/logr/testing" @@ -17,6 +15,7 @@ import ( "github.com/k8ssandra/k8ssandra-operator/pkg/test" promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "github.com/stretchr/testify/assert" ) @@ -37,7 +36,7 @@ func Test_reconcilereaperTelemetry_succeeds(t *testing.T) { reaper := test.NewReaper("test-reaper", "test-reaper-namespace") reaper.Spec.Telemetry = &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{k8ssandraapi.K8ssandraClusterNameLabel: "test-cluster-name", "test-label": "test"}, }, } diff --git a/controllers/reaper/vector_test.go b/controllers/reaper/vector_test.go index cb61f7253..f966131be 100644 --- a/controllers/reaper/vector_test.go +++ b/controllers/reaper/vector_test.go @@ -7,11 +7,11 @@ import ( reaperpkg "github.com/k8ssandra/k8ssandra-operator/pkg/reaper" "github.com/k8ssandra/k8ssandra-operator/pkg/test" "github.com/stretchr/testify/assert" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestCreateVectorTomlDefault(t *testing.T) { - telemetrySpec := &telemetryapi.TelemetrySpec{Vector: &telemetryapi.VectorSpec{Enabled: pointer.Bool(true)}} + telemetrySpec := &telemetryapi.TelemetrySpec{Vector: &telemetryapi.VectorSpec{Enabled: ptr.To(true)}} toml, err := CreateVectorToml(telemetrySpec) if err != nil { diff --git a/controllers/stargate/stargate_controller_test.go b/controllers/stargate/stargate_controller_test.go index b0db1f134..105584e38 100644 --- a/controllers/stargate/stargate_controller_test.go +++ b/controllers/stargate/stargate_controller_test.go @@ -6,14 +6,13 @@ import ( "testing" "time" - "k8s.io/utils/pointer" - telemetryapi "github.com/k8ssandra/k8ssandra-operator/apis/telemetry/v1alpha1" "github.com/k8ssandra/k8ssandra-operator/pkg/encryption" "github.com/k8ssandra/k8ssandra-operator/pkg/stargate" promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" "k8s.io/apimachinery/pkg/api/errors" k8serrors "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/utils/ptr" cassdcapi "github.com/k8ssandra/cass-operator/apis/cassandra/v1beta1" api "github.com/k8ssandra/k8ssandra-operator/apis/stargate/v1alpha1" @@ -126,7 +125,7 @@ func testCreateStargateSingleRack(t *testing.T, ctx context.Context, testClient StargateTemplate: api.StargateTemplate{ Telemetry: &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, }, }, @@ -582,7 +581,7 @@ func testCreateStargateEncryption(t *testing.T, ctx context.Context, testClient StargateTemplate: api.StargateTemplate{ Telemetry: &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, }, }, @@ -863,7 +862,7 @@ func testCreateStargateEncryptionExternalSecrets(t *testing.T, ctx context.Conte SecretsProvider: "external", Telemetry: &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, }, }, diff --git a/controllers/stargate/stargate_telemetry_reconciler_test.go b/controllers/stargate/stargate_telemetry_reconciler_test.go index b2083be91..3d0d1b091 100644 --- a/controllers/stargate/stargate_telemetry_reconciler_test.go +++ b/controllers/stargate/stargate_telemetry_reconciler_test.go @@ -6,8 +6,6 @@ import ( "context" "testing" - "k8s.io/utils/pointer" - k8ssandraapi "github.com/k8ssandra/k8ssandra-operator/apis/k8ssandra/v1alpha1" testlogr "github.com/go-logr/logr/testing" @@ -17,6 +15,7 @@ import ( "github.com/k8ssandra/k8ssandra-operator/pkg/test" promapi "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "github.com/stretchr/testify/assert" ) @@ -37,7 +36,7 @@ func Test_reconcileStargateTelemetry_succeeds(t *testing.T) { stargate := test.NewStargate("test-stargate", "test-stargate-namespace") stargate.Spec.Telemetry = &telemetryapi.TelemetrySpec{ Prometheus: &telemetryapi.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), CommonLabels: map[string]string{k8ssandraapi.K8ssandraClusterNameLabel: "test-cluster-name", "test-label": "test"}, }, } diff --git a/controllers/stargate/vector_test.go b/controllers/stargate/vector_test.go index 1070b720d..5883fc1ad 100644 --- a/controllers/stargate/vector_test.go +++ b/controllers/stargate/vector_test.go @@ -7,11 +7,11 @@ import ( stargatepkg "github.com/k8ssandra/k8ssandra-operator/pkg/stargate" "github.com/k8ssandra/k8ssandra-operator/pkg/test" "github.com/stretchr/testify/assert" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestCreateVectorTomlDefault(t *testing.T) { - telemetrySpec := &telemetryapi.TelemetrySpec{Vector: &telemetryapi.VectorSpec{Enabled: pointer.Bool(true)}} + telemetrySpec := &telemetryapi.TelemetrySpec{Vector: &telemetryapi.VectorSpec{Enabled: ptr.To(true)}} toml, err := CreateVectorToml(telemetrySpec) if err != nil { diff --git a/pkg/cassandra/config_premarshal_test.go b/pkg/cassandra/config_premarshal_test.go index 26b1983be..400bc8043 100644 --- a/pkg/cassandra/config_premarshal_test.go +++ b/pkg/cassandra/config_premarshal_test.go @@ -7,7 +7,7 @@ import ( "github.com/Masterminds/semver/v3" "github.com/stretchr/testify/assert" "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func Test_preMarshalConfig(t *testing.T) { @@ -104,23 +104,23 @@ func Test_preMarshalConfig(t *testing.T) { }, { "simple", - reflect.ValueOf(&simple{Simple1: pointer.String("foo"), Simple2: true}), + reflect.ValueOf(&simple{Simple1: ptr.To("foo"), Simple2: true}), semver.MustParse("3.11.14"), "cassandra", - map[string]interface{}{"foo": map[string]interface{}{"simple1": pointer.String("foo"), "simple2": true}}, + map[string]interface{}{"foo": map[string]interface{}{"simple1": ptr.To("foo"), "simple2": true}}, assert.NoError, }, { "simple DSE", - reflect.ValueOf(&simple{SimpleDSE: pointer.Bool(true)}), + reflect.ValueOf(&simple{SimpleDSE: ptr.To(true)}), semver.MustParse("6.8.25"), "dse", - map[string]interface{}{"foo": map[string]interface{}{"simple": map[string]interface{}{"dse": pointer.Bool(true)}}}, + map[string]interface{}{"foo": map[string]interface{}{"simple": map[string]interface{}{"dse": ptr.To(true)}}}, assert.NoError, }, { "simple server type mismatch", - reflect.ValueOf(&simple{SimpleDSE: pointer.Bool(true)}), + reflect.ValueOf(&simple{SimpleDSE: ptr.To(true)}), semver.MustParse("7.0.0"), "whatever", map[string]interface{}{}, @@ -129,22 +129,22 @@ func Test_preMarshalConfig(t *testing.T) { { "complex 3.11.x", reflect.ValueOf(&komplex{ - ManyRestrictions: pointer.String("qix"), - V3Only: pointer.Int(123), - V4Only: pointer.Int(456), + ManyRestrictions: ptr.To("qix"), + V3Only: ptr.To[int](123), + V4Only: ptr.To[int](456), RetainZero: true, nonExported: 789, Ignored: 1000, ChildNoRecurseRetainZeroV4Only: &simple{ - Simple1: pointer.String("foo"), + Simple1: ptr.To("foo"), Simple2: true, }, ChildRecurseNoPath: &simple{ - Simple1: pointer.String("bar"), + Simple1: ptr.To("bar"), Simple2: false, }, ChildRecurse: &simple{ - Simple1: pointer.String("qix"), + Simple1: ptr.To("qix"), Simple2: true, }, }), @@ -152,15 +152,15 @@ func Test_preMarshalConfig(t *testing.T) { "cassandra", map[string]interface{}{ "foo": map[string]interface{}{ - "many-restrictions-3x": pointer.String("qix"), - "3x-only": pointer.Int(123), + "many-restrictions-3x": ptr.To("qix"), + "3x-only": ptr.To[int](123), "retain-zero": true, // from ChildRecurseNoPath: - "simple1": pointer.String("bar"), + "simple1": ptr.To("bar"), //"simple2" omitted because zero value not retained // from ChildRecurse: "foo": map[string]interface{}{ - "simple1": pointer.String("qix"), + "simple1": ptr.To("qix"), "simple2": true, }, }, @@ -171,22 +171,22 @@ func Test_preMarshalConfig(t *testing.T) { { "complex 4.x", reflect.ValueOf(&komplex{ - ManyRestrictions: pointer.String("qix"), - V3Only: pointer.Int(123), - V4Only: pointer.Int(456), + ManyRestrictions: ptr.To("qix"), + V3Only: ptr.To[int](123), + V4Only: ptr.To[int](456), RetainZero: true, nonExported: 789, Ignored: 1000, ChildNoRecurseRetainZeroV4Only: &simple{ - Simple1: pointer.String("foo"), + Simple1: ptr.To("foo"), Simple2: true, }, ChildRecurseNoPath: &simple{ - Simple1: pointer.String("bar"), + Simple1: ptr.To("bar"), Simple2: false, }, ChildRecurse: &simple{ - Simple1: pointer.String("qix"), + Simple1: ptr.To("qix"), Simple2: true, }, }), @@ -194,21 +194,21 @@ func Test_preMarshalConfig(t *testing.T) { "cassandra", map[string]interface{}{ "foo": map[string]interface{}{ - "many-restrictions-4x": pointer.String("qix"), - "4x-only": pointer.Int(456), + "many-restrictions-4x": ptr.To("qix"), + "4x-only": ptr.To[int](456), "retain-zero": true, // from ChildRecurseNoPath: - "simple1": pointer.String("bar"), + "simple1": ptr.To("bar"), //"simple2" omitted because zero value not retained // from ChildRecurse: "foo": map[string]interface{}{ - "simple1": pointer.String("qix"), + "simple1": ptr.To("qix"), "simple2": true, }, }, // from ChildNoRecurseRetainZeroV4Only, which wasn't recursed hence was included as is "child-4x": &simple{ - Simple1: pointer.String("foo"), + Simple1: ptr.To("foo"), Simple2: true, }, }, @@ -217,19 +217,19 @@ func Test_preMarshalConfig(t *testing.T) { { "complex DSE 6.8", reflect.ValueOf(&dse{ - ManyRestrictionsDSE: pointer.String("qix"), + ManyRestrictionsDSE: ptr.To("qix"), ChildRecurseDSE: &simple{ - SimpleDSE: pointer.Bool(true), + SimpleDSE: ptr.To(true), }, }), semver.MustParse("6.8.25"), "dse", map[string]interface{}{ - "many-restrictions-dse": pointer.String("qix"), + "many-restrictions-dse": ptr.To("qix"), "parent": map[string]interface{}{ "foo": map[string]interface{}{ "simple": map[string]interface{}{ - "dse": pointer.Bool(true), + "dse": ptr.To(true), }, }, }, @@ -239,15 +239,15 @@ func Test_preMarshalConfig(t *testing.T) { { "complex DSE 6.8 with cassandra server type", reflect.ValueOf(&dse{ - ManyRestrictionsDSE: pointer.String("qix"), + ManyRestrictionsDSE: ptr.To("qix"), ChildRecurseDSE: &simple{ - SimpleDSE: pointer.Bool(true), + SimpleDSE: ptr.To(true), }, }), semver.MustParse("5.0.0"), "cassandra", map[string]interface{}{ - "many-restrictions-cassandra": pointer.String("qix"), + "many-restrictions-cassandra": ptr.To("qix"), }, assert.NoError, }, @@ -299,8 +299,8 @@ func Test_preMarshalConfig(t *testing.T) { { "key conflict simple", reflect.ValueOf(conflict1{ - Field1: pointer.Int(123), - Field2: pointer.String("foo"), + Field1: ptr.To[int](123), + Field2: ptr.To("foo"), }), semver.MustParse("4.1.0"), "cassandra", @@ -314,8 +314,8 @@ func Test_preMarshalConfig(t *testing.T) { { "key conflict recursive 1", reflect.ValueOf(conflict2{ - Field1: pointer.Int(123), - Field2: &simple{Simple1: pointer.String("foo")}, + Field1: ptr.To[int](123), + Field2: &simple{Simple1: ptr.To("foo")}, }), semver.MustParse("4.1.0"), "cassandra", @@ -329,8 +329,8 @@ func Test_preMarshalConfig(t *testing.T) { { "key conflict recursive 2", reflect.ValueOf(conflict3{ - Field1: pointer.Int(123), - Field2: &simple{Simple1: pointer.String("abc")}, + Field1: ptr.To[int](123), + Field2: &simple{Simple1: ptr.To("abc")}, }), semver.MustParse("4.1.0"), "cassandra", @@ -344,8 +344,8 @@ func Test_preMarshalConfig(t *testing.T) { { "key conflict recursive 3", reflect.ValueOf(conflict4{ - Field1: pointer.Int(123), - Field2: &simple{Simple1: pointer.String("abc")}, + Field1: ptr.To[int](123), + Field2: &simple{Simple1: ptr.To("abc")}, }), semver.MustParse("4.1.0"), "cassandra", diff --git a/pkg/cassandra/config_test.go b/pkg/cassandra/config_test.go index 02695ca90..03d99168c 100644 --- a/pkg/cassandra/config_test.go +++ b/pkg/cassandra/config_test.go @@ -5,8 +5,7 @@ import ( "github.com/Masterminds/semver/v3" "k8s.io/apimachinery/pkg/api/resource" - - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "github.com/Jeffail/gabs" api "github.com/k8ssandra/k8ssandra-operator/apis/k8ssandra/v1alpha1" @@ -169,7 +168,7 @@ func TestCreateJsonConfig(t *testing.T) { serverType: api.ServerDistributionCassandra, cassandraConfig: api.CassandraConfig{ JvmOptions: api.JvmOptions{ - GarbageCollector: pointer.String("G1GC"), + GarbageCollector: ptr.To("G1GC"), }, }, want: `{ @@ -184,7 +183,7 @@ func TestCreateJsonConfig(t *testing.T) { serverType: api.ServerDistributionCassandra, cassandraConfig: api.CassandraConfig{ JvmOptions: api.JvmOptions{ - GarbageCollector: pointer.String("ZGC"), + GarbageCollector: ptr.To("ZGC"), }, }, want: `{ @@ -199,7 +198,7 @@ func TestCreateJsonConfig(t *testing.T) { serverType: api.ServerDistributionDse, cassandraConfig: api.CassandraConfig{ JvmOptions: api.JvmOptions{ - GarbageCollector: pointer.String("ZGC"), + GarbageCollector: ptr.To("ZGC"), AdditionalJvm8ServerOptions: []string{"-XX:+UseConcMarkSweepGC"}, }, DseYaml: unstructured.Unstructured{ @@ -226,7 +225,7 @@ func TestCreateJsonConfig(t *testing.T) { serverType: api.ServerDistributionDse, cassandraConfig: api.CassandraConfig{ JvmOptions: api.JvmOptions{ - GarbageCollector: pointer.String("ZGC"), + GarbageCollector: ptr.To("ZGC"), AdditionalJvm8ServerOptions: []string{"-XX:ThreadPriorityPolicy=42", "-XX:+UseConcMarkSweepGC"}, AdditionalJvmServerOptions: []string{"-Dio.netty.maxDirectMemory=0"}, }, diff --git a/pkg/cassandra/datacenter_test.go b/pkg/cassandra/datacenter_test.go index 59989aa15..3dea22812 100644 --- a/pkg/cassandra/datacenter_test.go +++ b/pkg/cassandra/datacenter_test.go @@ -17,7 +17,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestCoalesce(t *testing.T) { @@ -214,14 +214,14 @@ func TestCoalesce(t *testing.T) { clusterTemplate: &api.CassandraClusterTemplate{ DatacenterOptions: api.DatacenterOptions{ Networking: &api.NetworkingConfig{ - HostNetwork: pointer.Bool(false), + HostNetwork: ptr.To(false), }, }, }, dcTemplate: &api.CassandraDatacenterTemplate{ DatacenterOptions: api.DatacenterOptions{ Networking: &api.NetworkingConfig{ - HostNetwork: pointer.Bool(true), + HostNetwork: ptr.To(true), }, }, }, @@ -348,7 +348,7 @@ func TestCoalesce(t *testing.T) { MgmtAPIHeap: &mgmtAPIHeap, Telemetry: &v1alpha1.TelemetrySpec{ Mcac: &v1alpha1.McacTelemetrySpec{ - Enabled: pointer.Bool(false), + Enabled: ptr.To(false), }, }, }, @@ -1340,7 +1340,7 @@ func TestNewDatacenter_MgmtAPIHeapSize_Unset(t *testing.T) { func TestNewDatacenter_AllowMultipleCassPerNodeSet(t *testing.T) { template := GetDatacenterConfig() - template.SoftPodAntiAffinity = pointer.Bool(true) + template.SoftPodAntiAffinity = ptr.To(true) dc, err := NewDatacenter( types.NamespacedName{Name: "testdc", Namespace: "test-namespace"}, &template, @@ -1395,7 +1395,7 @@ func TestValidateDatacenterConfig_Fail_NoServerVersion(t *testing.T) { func TestCDC(t *testing.T) { template := GetDatacenterConfig() template.CDC = &cassdcapi.CDCConfiguration{ - PulsarServiceUrl: pointer.String("pulsar://test-url"), + PulsarServiceUrl: ptr.To("pulsar://test-url"), } cassDC, err := NewDatacenter( types.NamespacedName{Name: "testdc", Namespace: "test-namespace"}, diff --git a/pkg/goalesce/utils_test.go b/pkg/goalesce/utils_test.go index 989e2f729..bef9576fa 100644 --- a/pkg/goalesce/utils_test.go +++ b/pkg/goalesce/utils_test.go @@ -6,7 +6,7 @@ import ( cassdcapi "github.com/k8ssandra/cass-operator/apis/cassandra/v1beta1" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestMergeCRs(t *testing.T) { @@ -31,20 +31,20 @@ func TestMergeCRs(t *testing.T) { { name: "nil vs non-nil", cluster: nil, - dc: Foo{Enabled: pointer.Bool(true), Text: "foo", Number: pointer.Int(123)}, - want: Foo{Enabled: pointer.Bool(true), Text: "foo", Number: pointer.Int(123)}, + dc: Foo{Enabled: ptr.To(true), Text: "foo", Number: ptr.To[int](123)}, + want: Foo{Enabled: ptr.To(true), Text: "foo", Number: ptr.To[int](123)}, }, { name: "non-nil vs nil", - cluster: Foo{Enabled: pointer.Bool(true), Text: "foo", Number: pointer.Int(123)}, + cluster: Foo{Enabled: ptr.To(true), Text: "foo", Number: ptr.To[int](123)}, dc: nil, - want: Foo{Enabled: pointer.Bool(true), Text: "foo", Number: pointer.Int(123)}, + want: Foo{Enabled: ptr.To(true), Text: "foo", Number: ptr.To[int](123)}, }, { name: "non-nil vs non-nil", - cluster: Foo{Enabled: pointer.Bool(true), Text: "foo", Number: pointer.Int(123)}, - dc: Foo{Enabled: pointer.Bool(false), Text: "bar", Number: pointer.Int(456)}, - want: Foo{Enabled: pointer.Bool(false), Text: "bar", Number: pointer.Int(456)}, + cluster: Foo{Enabled: ptr.To(true), Text: "foo", Number: ptr.To[int](123)}, + dc: Foo{Enabled: ptr.To(false), Text: "bar", Number: ptr.To[int](456)}, + want: Foo{Enabled: ptr.To(false), Text: "bar", Number: ptr.To[int](456)}, }, // special cases { diff --git a/pkg/medusa/reconcile.go b/pkg/medusa/reconcile.go index 1eef6e0a2..eadcf82c9 100644 --- a/pkg/medusa/reconcile.go +++ b/pkg/medusa/reconcile.go @@ -14,7 +14,7 @@ import ( "github.com/k8ssandra/k8ssandra-operator/pkg/images" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "github.com/go-logr/logr" "github.com/k8ssandra/k8ssandra-operator/pkg/cassandra" @@ -507,9 +507,9 @@ func PurgeCronJob(dcConfig *cassandra.DatacenterConfig, clusterName, namespace s }, Spec: batchv1.CronJobSpec{ Schedule: "0 0 * * *", - Suspend: pointer.Bool(false), - SuccessfulJobsHistoryLimit: pointer.Int32(3), - FailedJobsHistoryLimit: pointer.Int32(1), + Suspend: ptr.To(false), + SuccessfulJobsHistoryLimit: ptr.To[int32](3), + FailedJobsHistoryLimit: ptr.To[int32](1), JobTemplate: batchv1.JobTemplateSpec{ Spec: batchv1.JobSpec{ Template: corev1.PodTemplateSpec{ diff --git a/pkg/reaper/deployment_test.go b/pkg/reaper/deployment_test.go index 656fe0053..b3086c0dc 100644 --- a/pkg/reaper/deployment_test.go +++ b/pkg/reaper/deployment_test.go @@ -16,7 +16,7 @@ import ( "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/intstr" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestNewDeployment(t *testing.T) { @@ -50,7 +50,7 @@ func TestNewDeployment(t *testing.T) { labels := createServiceAndDeploymentLabels(reaper) podLabels := utils.MergeMap(labels, reaper.Spec.ResourceMeta.Pods.Labels) logger := testlogr.NewTestLogger(t) - deployment := NewDeployment(reaper, newTestDatacenter(), pointer.String("keystore-password"), pointer.String("truststore-password"), logger) + deployment := NewDeployment(reaper, newTestDatacenter(), ptr.To("keystore-password"), ptr.To("truststore-password"), logger) assert.Equal(t, reaper.Namespace, deployment.Namespace) assert.Equal(t, reaper.Name, deployment.Name) diff --git a/pkg/reaper/vector_test.go b/pkg/reaper/vector_test.go index 9032e31a9..a297a36a9 100644 --- a/pkg/reaper/vector_test.go +++ b/pkg/reaper/vector_test.go @@ -11,11 +11,11 @@ import ( "github.com/stretchr/testify/assert" v1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestConfigureVector(t *testing.T) { - telemetrySpec := &telemetryapi.TelemetrySpec{Vector: &telemetryapi.VectorSpec{Enabled: pointer.Bool(true)}} + telemetrySpec := &telemetryapi.TelemetrySpec{Vector: &telemetryapi.VectorSpec{Enabled: ptr.To(true)}} reaper := &api.Reaper{} reaper.Spec.Telemetry = telemetrySpec diff --git a/pkg/stargate/deployments_test.go b/pkg/stargate/deployments_test.go index ded1cb1d4..c861fd85e 100644 --- a/pkg/stargate/deployments_test.go +++ b/pkg/stargate/deployments_test.go @@ -4,8 +4,6 @@ import ( "strings" "testing" - "k8s.io/utils/pointer" - "github.com/k8ssandra/k8ssandra-operator/pkg/images" testlogr "github.com/go-logr/logr/testing" @@ -19,6 +17,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" ) const ( @@ -691,7 +690,7 @@ func testNewDeploymentsEncryption(t *testing.T) { func testNewDeploymentsAuthentication(t *testing.T) { t.Run("disabled", func(t *testing.T) { sg := stargate.DeepCopy() - sg.Spec.Auth = pointer.Bool(false) + sg.Spec.Auth = ptr.To(false) logger := testlogr.NewTestLogger(t) deployments := NewDeployments(sg, dc, logger) require.Len(t, deployments, 1) @@ -702,7 +701,7 @@ func testNewDeploymentsAuthentication(t *testing.T) { }) t.Run("table-based", func(t *testing.T) { sg := stargate.DeepCopy() - sg.Spec.Auth = pointer.Bool(true) + sg.Spec.Auth = ptr.To(true) sg.Spec.AuthOptions = &api.AuthOptions{ ApiAuthMethod: "Table", TokenTtlSeconds: 123, @@ -718,7 +717,7 @@ func testNewDeploymentsAuthentication(t *testing.T) { }) t.Run("JWT-based", func(t *testing.T) { sg := stargate.DeepCopy() - sg.Spec.Auth = pointer.Bool(true) + sg.Spec.Auth = ptr.To(true) sg.Spec.AuthOptions = &api.AuthOptions{ ApiAuthMethod: "JWT", JwtProviderUrl: "https://auth.example.com/auth/realms/stargate/protocol/openid-connect/token", diff --git a/pkg/stargate/vector_test.go b/pkg/stargate/vector_test.go index 9974a34b1..4a1013a4b 100644 --- a/pkg/stargate/vector_test.go +++ b/pkg/stargate/vector_test.go @@ -11,11 +11,11 @@ import ( "github.com/stretchr/testify/assert" v1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestConfigureVector(t *testing.T) { - telemetrySpec := &telemetryapi.TelemetrySpec{Vector: &telemetryapi.VectorSpec{Enabled: pointer.Bool(true)}} + telemetrySpec := &telemetryapi.TelemetrySpec{Vector: &telemetryapi.VectorSpec{Enabled: ptr.To(true)}} stargate := &api.Stargate{} stargate.Spec.Telemetry = telemetrySpec diff --git a/pkg/telemetry/cassandra_metrics_filters_test.go b/pkg/telemetry/cassandra_metrics_filters_test.go index d32082ca0..b938e0e9b 100644 --- a/pkg/telemetry/cassandra_metrics_filters_test.go +++ b/pkg/telemetry/cassandra_metrics_filters_test.go @@ -1,7 +1,6 @@ package telemetry import ( - "k8s.io/utils/pointer" "strings" "testing" @@ -9,6 +8,7 @@ import ( "github.com/k8ssandra/k8ssandra-operator/pkg/cassandra" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" + "k8s.io/utils/ptr" ) // Test_InjectCassandraTelemetryFilters tests that metrics filters from the CRD are correctly injected. @@ -28,7 +28,7 @@ func Test_InjectCassandraTelemetryFilters(t *testing.T) { telemetrySpec := &telemetry.TelemetrySpec{ Prometheus: &telemetry.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, Mcac: &telemetry.McacTelemetrySpec{ MetricFilters: &[]string{ @@ -61,7 +61,7 @@ func Test_InjectCassandraTelemetryFiltersDefaults(t *testing.T) { telemetrySpec := &telemetry.TelemetrySpec{ Prometheus: &telemetry.PrometheusTelemetrySpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), }, } diff --git a/pkg/telemetry/validation_test.go b/pkg/telemetry/validation_test.go index 09091d25e..f2e647d14 100644 --- a/pkg/telemetry/validation_test.go +++ b/pkg/telemetry/validation_test.go @@ -5,7 +5,7 @@ import ( telemetryapi "github.com/k8ssandra/k8ssandra-operator/apis/telemetry/v1alpha1" "github.com/stretchr/testify/assert" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestSpecIsValid(t *testing.T) { @@ -35,13 +35,13 @@ func TestSpecIsValid(t *testing.T) { }, { "prom not enabled, prom not installed", - &telemetryapi.TelemetrySpec{Prometheus: &telemetryapi.PrometheusTelemetrySpec{Enabled: pointer.Bool(false)}}, + &telemetryapi.TelemetrySpec{Prometheus: &telemetryapi.PrometheusTelemetrySpec{Enabled: ptr.To(false)}}, false, true, }, { "prom enabled, prom not installed", - &telemetryapi.TelemetrySpec{Prometheus: &telemetryapi.PrometheusTelemetrySpec{Enabled: pointer.Bool(true)}}, + &telemetryapi.TelemetrySpec{Prometheus: &telemetryapi.PrometheusTelemetrySpec{Enabled: ptr.To(true)}}, false, false, }, @@ -65,13 +65,13 @@ func TestSpecIsValid(t *testing.T) { }, { "prom not enabled, prom installed", - &telemetryapi.TelemetrySpec{Prometheus: &telemetryapi.PrometheusTelemetrySpec{Enabled: pointer.Bool(false)}}, + &telemetryapi.TelemetrySpec{Prometheus: &telemetryapi.PrometheusTelemetrySpec{Enabled: ptr.To(false)}}, true, true, }, { "prom enabled, prom installed", - &telemetryapi.TelemetrySpec{Prometheus: &telemetryapi.PrometheusTelemetrySpec{Enabled: pointer.Bool(true)}}, + &telemetryapi.TelemetrySpec{Prometheus: &telemetryapi.PrometheusTelemetrySpec{Enabled: ptr.To(true)}}, true, true, }, diff --git a/pkg/telemetry/vector_test.go b/pkg/telemetry/vector_test.go index ef15f5b9e..d80fa2688 100644 --- a/pkg/telemetry/vector_test.go +++ b/pkg/telemetry/vector_test.go @@ -13,11 +13,11 @@ import ( "github.com/stretchr/testify/require" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" ) func TestInjectCassandraVectorAgentConfig(t *testing.T) { - telemetrySpec := &telemetry.TelemetrySpec{Vector: &telemetry.VectorSpec{Enabled: pointer.Bool(true)}} + telemetrySpec := &telemetry.TelemetrySpec{Vector: &telemetry.VectorSpec{Enabled: ptr.To(true)}} dcConfig := &cassandra.DatacenterConfig{ Meta: k8ssandra.EmbeddedObjectMeta{ Name: "dc1", @@ -40,7 +40,7 @@ func TestInjectCassandraVectorAgentConfig(t *testing.T) { } func TestCreateCassandraVectorTomlDefault(t *testing.T) { - telemetrySpec := &telemetry.TelemetrySpec{Vector: &telemetry.VectorSpec{Enabled: pointer.Bool(true)}} + telemetrySpec := &telemetry.TelemetrySpec{Vector: &telemetry.VectorSpec{Enabled: ptr.To(true)}} toml, err := CreateCassandraVectorToml(telemetrySpec, true) if err != nil { @@ -52,9 +52,9 @@ func TestCreateCassandraVectorTomlDefault(t *testing.T) { } func TestCreateCassandraVectorTomlMcacDisabled(t *testing.T) { - telemetrySpec := &telemetry.TelemetrySpec{Mcac: &telemetry.McacTelemetrySpec{Enabled: pointer.Bool(false)}, + telemetrySpec := &telemetry.TelemetrySpec{Mcac: &telemetry.McacTelemetrySpec{Enabled: ptr.To(false)}, Vector: &telemetry.VectorSpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Components: &telemetry.VectorComponentsSpec{ Sinks: []telemetry.VectorSinkSpec{ { @@ -91,7 +91,7 @@ func TestBuildCustomVectorToml(t *testing.T) { "Single sink", &telemetry.TelemetrySpec{ Vector: &telemetry.VectorSpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Components: &telemetry.VectorComponentsSpec{ Sinks: []telemetry.VectorSinkSpec{ { @@ -116,7 +116,7 @@ inputs = ["test", "test2"] "Source, sink and transform", &telemetry.TelemetrySpec{ Vector: &telemetry.VectorSpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Components: &telemetry.VectorComponentsSpec{ Sources: []telemetry.VectorSourceSpec{ { @@ -192,7 +192,7 @@ func TestBuildCustomConfigWithDefaults(t *testing.T) { assert := assert.New(t) telemetrySpec := &telemetry.TelemetrySpec{ Vector: &telemetry.VectorSpec{ - Enabled: pointer.Bool(true), + Enabled: ptr.To(true), Components: &telemetry.VectorComponentsSpec{ Sinks: []telemetry.VectorSinkSpec{ { diff --git a/test/e2e/auth_test.go b/test/e2e/auth_test.go index 3d90dfb56..16e642a97 100644 --- a/test/e2e/auth_test.go +++ b/test/e2e/auth_test.go @@ -18,7 +18,7 @@ import ( "github.com/stretchr/testify/require" "gopkg.in/resty.v1" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -114,7 +114,7 @@ func toggleAuthentication(t *testing.T, f *framework.E2eFramework, ctx context.C err := f.Client.Get(ctx, kcKey, &kc) require.NoError(t, err, "failed to get K8ssandraCluster %v", kcKey) patch := client.MergeFromWithOptions(kc.DeepCopy(), client.MergeFromWithOptimisticLock{}) - kc.Spec.Auth = pointer.Bool(on) + kc.Spec.Auth = ptr.To(on) err = f.Client.Patch(ctx, &kc, patch) require.NoError(t, err, "failed to patch K8ssandraCluster %v", kcKey) } diff --git a/test/e2e/reaper_test.go b/test/e2e/reaper_test.go index 282f72c5d..3a2b0a317 100644 --- a/test/e2e/reaper_test.go +++ b/test/e2e/reaper_test.go @@ -18,7 +18,7 @@ import ( "github.com/stretchr/testify/require" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -45,7 +45,7 @@ func createSingleReaper(t *testing.T, ctx context.Context, namespace string, f * err := f.Client.Get(ctx, kcKey, kc) require.NoError(err, "failed to get K8ssandraCluster in namespace %s", namespace) reaperVectorPatch := client.MergeFromWithOptions(kc.DeepCopy(), client.MergeFromWithOptimisticLock{}) - kc.Spec.Reaper.Telemetry.Vector.Enabled = pointer.Bool(false) + kc.Spec.Reaper.Telemetry.Vector.Enabled = ptr.To(false) err = f.Client.Patch(ctx, kc, reaperVectorPatch) require.NoError(err, "failed to patch K8ssandraCluster in namespace %s", namespace) checkReaperReady(t, f, ctx, reaperKey) @@ -57,7 +57,7 @@ func createSingleReaper(t *testing.T, ctx context.Context, namespace string, f * err = f.Client.Get(ctx, kcKey, kc) require.NoError(err, "failed to get K8ssandraCluster in namespace %s", namespace) reaperVectorPatch = client.MergeFromWithOptions(kc.DeepCopy(), client.MergeFromWithOptimisticLock{}) - kc.Spec.Reaper.Telemetry.Vector.Enabled = pointer.Bool(true) + kc.Spec.Reaper.Telemetry.Vector.Enabled = ptr.To(true) err = f.Client.Patch(ctx, kc, reaperVectorPatch) require.NoError(err, "failed to patch K8ssandraCluster in namespace %s", namespace) checkReaperReady(t, f, ctx, reaperKey) diff --git a/test/e2e/suite_test.go b/test/e2e/suite_test.go index a29bdf51d..4bd67e8cf 100644 --- a/test/e2e/suite_test.go +++ b/test/e2e/suite_test.go @@ -31,7 +31,7 @@ import ( "github.com/rs/zerolog" "github.com/rs/zerolog/log" "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/client" cassdcapi "github.com/k8ssandra/cass-operator/apis/cassandra/v1beta1" @@ -365,7 +365,7 @@ func TestOperator(t *testing.T) { t.Run("UpgradeOperatorImage", e2eTest(ctx, &e2eTestOpts{ testFunc: createSingleDatacenterClusterWithUpgrade, fixture: framework.NewTestFixture("single-dc-upgrade", controlPlane), - initialVersion: pointer.String("v1.4.1"), // Has to be the Helm chart version, not the operator image tag + initialVersion: ptr.To("v1.4.1"), // Has to be the Helm chart version, not the operator image tag })) t.Run("StargateJwt", e2eTest(ctx, &e2eTestOpts{ testFunc: stargateJwt, @@ -822,7 +822,7 @@ func createSingleDatacenterCluster(t *testing.T, ctx context.Context, namespace err = f.Client.Get(ctx, kcKey, k8ssandra) require.NoError(err, "failed to get K8ssandraCluster in namespace %s", namespace) stargateVectorPatch := client.MergeFromWithOptions(k8ssandra.DeepCopy(), client.MergeFromWithOptimisticLock{}) - k8ssandra.Spec.Cassandra.Datacenters[0].Stargate.Telemetry.Vector.Enabled = pointer.Bool(false) + k8ssandra.Spec.Cassandra.Datacenters[0].Stargate.Telemetry.Vector.Enabled = ptr.To(false) err = f.Client.Patch(ctx, k8ssandra, stargateVectorPatch) require.NoError(err, "failed to patch K8ssandraCluster in namespace %s", namespace) checkStargateReady(t, f, ctx, stargateKey) @@ -834,7 +834,7 @@ func createSingleDatacenterCluster(t *testing.T, ctx context.Context, namespace err = f.Client.Get(ctx, kcKey, k8ssandra) require.NoError(err, "failed to get K8ssandraCluster in namespace %s", namespace) stargateVectorPatch = client.MergeFromWithOptions(k8ssandra.DeepCopy(), client.MergeFromWithOptimisticLock{}) - k8ssandra.Spec.Cassandra.Datacenters[0].Stargate.Telemetry.Vector.Enabled = pointer.Bool(true) + k8ssandra.Spec.Cassandra.Datacenters[0].Stargate.Telemetry.Vector.Enabled = ptr.To(true) err = f.Client.Patch(ctx, k8ssandra, stargateVectorPatch) require.NoError(err, "failed to patch K8ssandraCluster in namespace %s", namespace) checkStargateReady(t, f, ctx, stargateKey) @@ -923,8 +923,8 @@ func createSingleDatacenterCluster(t *testing.T, ctx context.Context, namespace err = f.Client.Get(ctx, kcKey, k8ssandra) require.NoError(err, "failed to get K8ssandraCluster in namespace %s", namespace) vectorPatch := client.MergeFromWithOptions(k8ssandra.DeepCopy(), client.MergeFromWithOptimisticLock{}) - k8ssandra.Spec.Cassandra.Telemetry.Vector.Enabled = pointer.Bool(false) - k8ssandra.Spec.Cassandra.Datacenters[0].Stargate.Telemetry.Vector.Enabled = pointer.Bool(false) + k8ssandra.Spec.Cassandra.Telemetry.Vector.Enabled = ptr.To(false) + k8ssandra.Spec.Cassandra.Datacenters[0].Stargate.Telemetry.Vector.Enabled = ptr.To(false) err = f.Client.Patch(ctx, k8ssandra, vectorPatch) require.NoError(err, "failed to patch K8ssandraCluster in namespace %s", namespace) checkDatacenterReady(t, ctx, dcKey, f) diff --git a/test/framework/e2e_framework.go b/test/framework/e2e_framework.go index 858b6737b..751f491f9 100644 --- a/test/framework/e2e_framework.go +++ b/test/framework/e2e_framework.go @@ -387,7 +387,7 @@ func (f *E2eFramework) CreateMedusaBucket(namespace string) error { // Wait for job to succeed f.logger.Info("Waiting for setup-minio job to succeed") opts := kubectl.Options{Namespace: namespace, Context: k8sContext} - err := wait.PollWithContext(context.Background(), 5*time.Second, 5*time.Minute, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, 5*time.Minute, false, func(ctx context.Context) (bool, error) { if err := kubectl.JobSuccess(ctx, opts, namespace, "setup-minio"); err != nil { f.logger.Error(err, "Waiting for setup-minio job to succeed") return false, nil @@ -550,7 +550,7 @@ func (f *E2eFramework) DeleteNamespace(name string, timeout, interval time.Durat } // Should this wait.Poll call be per cluster? - return wait.Poll(interval, timeout, func() (bool, error) { + return wait.PollUntilContextTimeout(context.TODO(), interval, timeout, false, func(context.Context) (bool, error) { for _, remoteClient := range f.remoteClients { err := remoteClient.Get(context.TODO(), types.NamespacedName{Name: name}, namespace.DeepCopy()) diff --git a/test/framework/framework.go b/test/framework/framework.go index 926985989..1c7e6a226 100644 --- a/test/framework/framework.go +++ b/test/framework/framework.go @@ -463,7 +463,7 @@ func (f *Framework) WaitForDeploymentToBeReady(key ClusterKey, timeout, interval if len(key.K8sContext) == 0 { for k8sContext := range f.remoteClients { opts := kubectl.Options{Namespace: key.Namespace, Context: k8sContext} - err := wait.PollUntilContextTimeout(context.Background(), interval, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(context.Background(), interval, timeout, false, func(ctx context.Context) (bool, error) { if err := kubectl.RolloutStatus(ctx, opts, "Deployment", key.Name); err != nil { return false, err } @@ -479,7 +479,7 @@ func (f *Framework) WaitForDeploymentToBeReady(key ClusterKey, timeout, interval return f.k8sContextNotFound(key.K8sContext) } opts := kubectl.Options{Namespace: key.Namespace, Context: key.K8sContext} - return wait.PollWithContext(context.Background(), interval, timeout, func(ctx context.Context) (bool, error) { + return wait.PollUntilContextTimeout(context.Background(), interval, timeout, false, func(ctx context.Context) (bool, error) { if err := kubectl.RolloutStatus(ctx, opts, "Deployment", key.Name); err != nil { return false, err } @@ -498,7 +498,7 @@ func (f *Framework) DeleteK8ssandraCluster(ctx context.Context, key client.Objec if err != nil { return err } - return wait.Poll(interval, timeout, func() (bool, error) { + return wait.PollUntilContextTimeout(context.TODO(), interval, timeout, false, func(context.Context) (bool, error) { err := f.Client.Get(ctx, key, kc) return err != nil && errors.IsNotFound(err), nil }) @@ -513,7 +513,7 @@ func (f *Framework) DeleteK8ssandraClusters(namespace string, interval, timeout return err } - return wait.Poll(interval, timeout, func() (bool, error) { + return wait.PollUntilContextTimeout(context.TODO(), interval, timeout, false, func(context.Context) (bool, error) { list := &api.K8ssandraClusterList{} err := f.Client.List(context.Background(), list, client.InNamespace(namespace)) if err != nil { @@ -532,7 +532,7 @@ func (f *Framework) DeleteCassandraDatacenters(namespace string, interval, timeo f.logger.Error(err, "Failed to delete CassandraDatacenters") } - return wait.Poll(interval, timeout, func() (bool, error) { + return wait.PollUntilContextTimeout(context.TODO(), interval, timeout, false, func(context.Context) (bool, error) { list := &cassdcapi.CassandraDatacenterList{} err := f.Client.List(context.Background(), list, client.InNamespace(namespace)) if err != nil {