Skip to content

Commit

Permalink
Very annoying deprecation errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
Miles-Garnsey committed May 13, 2024
1 parent 22c2225 commit e49db2f
Show file tree
Hide file tree
Showing 30 changed files with 176 additions and 181 deletions.
13 changes: 7 additions & 6 deletions apis/stargate/v1alpha1/stargate_types_test.go
Original file line number Diff line number Diff line change
@@ -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 (
Expand Down Expand Up @@ -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"}},
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"}},
Expand Down Expand Up @@ -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
Expand Down
44 changes: 22 additions & 22 deletions apis/telemetry/v1alpha1/telemetry_methods_test.go
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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",
},
Expand All @@ -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",
},
Expand All @@ -100,15 +100,15 @@ 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",
},
},
},
want: &TelemetrySpec{
Prometheus: &PrometheusTelemetrySpec{
Enabled: pointer.Bool(true),
Enabled: ptr.To(true),
CommonLabels: map[string]string{
"key1": "value1",
},
Expand All @@ -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",
Expand All @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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,
},
}
Expand Down
10 changes: 5 additions & 5 deletions controllers/k8ssandra/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down
6 changes: 3 additions & 3 deletions controllers/k8ssandra/cassandra_metrics_agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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),
},
},
},
Expand All @@ -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{},
Expand Down
11 changes: 5 additions & 6 deletions controllers/k8ssandra/cassandra_telemetry_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package k8ssandra
import (
"context"

"k8s.io/utils/pointer"

"testing"

testlogr "github.com/go-logr/logr/testing"
Expand All @@ -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"
)
Expand Down Expand Up @@ -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"},
},
},
Expand Down Expand Up @@ -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),
},
}

Expand All @@ -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),
},
},
},
Expand Down
12 changes: 6 additions & 6 deletions controllers/k8ssandra/k8ssandracluster_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{},
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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{
Expand All @@ -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"),
},
},
},
Expand Down
Loading

0 comments on commit e49db2f

Please sign in to comment.