Skip to content

Commit

Permalink
feat: convert boolPointer to a generic Pointer func
Browse files Browse the repository at this point in the history
  • Loading branch information
tuusberg committed Dec 30, 2023
1 parent 668c52f commit 47f308b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/plugin/restorepluginv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (p *RestorePluginV2) Execute(input *velero.RestoreItemActionExecuteInput) (

// This is where the job gets suspended:
p.log.Infof("CronJob %s/%s will be suspended", cronJob.Namespace, cronJob.Name)
cronJob.Spec.Suspend = boolPointer(true)
cronJob.Spec.Suspend = Pointer(true)

// Convert the CronJob back to unstructured data:
cronJobUnstructured, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&cronJob)
Expand Down
2 changes: 1 addition & 1 deletion internal/plugin/restorepluginv2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestRestorePluginV2_Execute(t *testing.T) {
},
Spec: batchv1.CronJobSpec{
Schedule: "0 0 * * *",
Suspend: boolPointer(false),
Suspend: Pointer(false),
},
}

Expand Down
4 changes: 2 additions & 2 deletions internal/plugin/utils.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package plugin

func boolPointer(b bool) *bool {
return &b
func Pointer[T any](v T) *T {
return &v
}

0 comments on commit 47f308b

Please sign in to comment.