diff --git a/controllers/storagecluster/exporter.go b/controllers/storagecluster/exporter.go index e5b850ce3e..90e95cedd8 100644 --- a/controllers/storagecluster/exporter.go +++ b/controllers/storagecluster/exporter.go @@ -15,6 +15,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/ptr" controllerutil "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" ) @@ -276,12 +277,6 @@ func createMetricsExporterServiceMonitor(ctx context.Context, r *StorageClusterR } func deployMetricsExporter(ctx context.Context, r *StorageClusterReconciler, instance *ocsv1.StorageCluster) error { - var ( - falsePtr = new(bool) // defaults to 'false' - truePtr = new(bool) - ) - *truePtr = true - currentDep := &appsv1.Deployment{ ObjectMeta: metav1.ObjectMeta{ Name: metricsExporterName, @@ -301,8 +296,8 @@ func deployMetricsExporter(ctx context.Context, r *StorageClusterReconciler, ins Namespace: instance.Namespace, OwnerReferences: []metav1.OwnerReference{{ APIVersion: instance.APIVersion, - BlockOwnerDeletion: falsePtr, - Controller: falsePtr, + BlockOwnerDeletion: ptr.To(false), + Controller: ptr.To(false), Kind: instance.Kind, Name: instance.Name, UID: instance.UID, @@ -337,7 +332,7 @@ func deployMetricsExporter(ctx context.Context, r *StorageClusterReconciler, ins {ContainerPort: 8081}, }, SecurityContext: &corev1.SecurityContext{ - RunAsNonRoot: truePtr, + RunAsNonRoot: ptr.To(true), }, VolumeMounts: []corev1.VolumeMount{{ Name: "ceph-config", diff --git a/controllers/util/predicates_test.go b/controllers/util/predicates_test.go index 773ffb8496..9ea93308b0 100644 --- a/controllers/util/predicates_test.go +++ b/controllers/util/predicates_test.go @@ -8,11 +8,11 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/utils/ptr" "sigs.k8s.io/controller-runtime/pkg/event" "sigs.k8s.io/controller-runtime/pkg/predicate" ) -var one = int64(1) var now = metav1.NewTime(time.Now()) func TestComposePredicatesUpdate(t *testing.T) { @@ -50,10 +50,10 @@ func TestComposePredicatesUpdate(t *testing.T) { Namespace: "foo", SelfLink: "foo", UID: types.UID("foo"), - Generation: one, + Generation: 1, CreationTimestamp: now, DeletionTimestamp: &now, - DeletionGracePeriodSeconds: &one, + DeletionGracePeriodSeconds: ptr.To(int64(1)), OwnerReferences: []metav1.OwnerReference{{}}, ManagedFields: []metav1.ManagedFieldsEntry{{}}, }, @@ -127,10 +127,10 @@ func TestMetadataChangedPredicateUpdate(t *testing.T) { SelfLink: "foo", UID: types.UID("foo"), ResourceVersion: "foo", - Generation: one, + Generation: 1, CreationTimestamp: now, DeletionTimestamp: &now, - DeletionGracePeriodSeconds: &one, + DeletionGracePeriodSeconds: ptr.To(int64(1)), OwnerReferences: []metav1.OwnerReference{{}}, ManagedFields: []metav1.ManagedFieldsEntry{{}}, }, diff --git a/tools/csv-merger/csv-merger.go b/tools/csv-merger/csv-merger.go index 9cccb1f284..48ee9d9798 100644 --- a/tools/csv-merger/csv-merger.go +++ b/tools/csv-merger/csv-merger.go @@ -24,6 +24,7 @@ import ( extv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/utils/ptr" ) var ( @@ -930,7 +931,6 @@ func copyManifests() { func getUXBackendServerDeployment() appsv1.DeploymentSpec { replica := int32(1) - ptrToTrue := true deployment := appsv1.DeploymentSpec{ Replicas: &replica, Selector: &metav1.LabelSelector{ @@ -1023,7 +1023,7 @@ func getUXBackendServerDeployment() appsv1.DeploymentSpec { VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ SecretName: "onboarding-private-key", - Optional: &ptrToTrue, + Optional: ptr.To(true), }, }, },