Skip to content

Commit f9297b6

Browse files
committed
Replace custom pointer fn with k8s ptr package
Signed-off-by: Ales Raszka <[email protected]>
1 parent b84b069 commit f9297b6

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

controllers/backupcronjob/backupcronjob_controller.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
2222
"sigs.k8s.io/controller-runtime/pkg/reconcile"
2323

24+
"k8s.io/utils/ptr"
25+
2426
dw "github.com/devfile/api/v2/pkg/apis/workspaces/v1alpha2"
2527
controllerv1alpha1 "github.com/devfile/devworkspace-operator/apis/controller/v1alpha1"
2628
"github.com/devfile/devworkspace-operator/internal/images"
@@ -345,10 +347,6 @@ func (r *BackupCronJobReconciler) wasStoppedSinceLastBackup(workspace *dw.DevWor
345347
return false
346348
}
347349

348-
func ptrInt64(i int64) *int64 { return &i }
349-
func ptrInt32(i int32) *int32 { return &i }
350-
func ptrBool(b bool) *bool { return &b }
351-
352350
// createBackupJob creates a Kubernetes Job to back up the workspace's PVC data.
353351
func (r *BackupCronJobReconciler) createBackupJob(
354352
workspace *dw.DevWorkspace,
@@ -394,7 +392,7 @@ func (r *BackupCronJobReconciler) createBackupJob(
394392
ServiceAccountName: JobRunnerSAName,
395393
RestartPolicy: corev1.RestartPolicyNever,
396394
SecurityContext: &corev1.PodSecurityContext{
397-
FSGroup: ptrInt64(0),
395+
FSGroup: ptr.To[int64](0),
398396
},
399397
Containers: []corev1.Container{
400398
{
@@ -428,8 +426,8 @@ func (r *BackupCronJobReconciler) createBackupJob(
428426
},
429427
},
430428
SecurityContext: &corev1.SecurityContext{
431-
RunAsUser: ptrInt64(0),
432-
AllowPrivilegeEscalation: ptrBool(false),
429+
RunAsUser: ptr.To[int64](0),
430+
AllowPrivilegeEscalation: ptr.To[bool](false),
433431
},
434432
},
435433
},

0 commit comments

Comments
 (0)