drop deprecated pointer package in controller
Signed-off-by: liyuerich <yue.li@daocloud.io> Update job_controller.go Signed-off-by: liyuerich <yue.li@daocloud.io>
This commit is contained in:
		| @@ -48,7 +48,7 @@ import ( | ||||
| 	"k8s.io/kubernetes/pkg/controller" | ||||
| 	"k8s.io/kubernetes/pkg/controller/cronjob/metrics" | ||||
| 	jobutil "k8s.io/kubernetes/pkg/controller/job/util" | ||||
| 	"k8s.io/utils/pointer" | ||||
| 	"k8s.io/utils/ptr" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| @@ -389,7 +389,7 @@ func (jm *ControllerV2) updateCronJob(logger klog.Logger, old interface{}, curr | ||||
| 	// if the change in schedule results in next requeue having to be sooner than it already was, | ||||
| 	// it will be handled here by the queue. If the next requeue is further than previous schedule, | ||||
| 	// the sync loop will essentially be a no-op for the already queued key with old schedule. | ||||
| 	if oldCJ.Spec.Schedule != newCJ.Spec.Schedule || !pointer.StringEqual(oldCJ.Spec.TimeZone, newCJ.Spec.TimeZone) { | ||||
| 	if oldCJ.Spec.Schedule != newCJ.Spec.Schedule || !ptr.Equal(oldCJ.Spec.TimeZone, newCJ.Spec.TimeZone) { | ||||
| 		// schedule changed, change the requeue time, pass nil recorder so that syncCronJob will output any warnings | ||||
| 		sched, err := cron.ParseStandard(formatSchedule(newCJ, nil)) | ||||
| 		if err != nil { | ||||
| @@ -494,7 +494,7 @@ func (jm *ControllerV2) syncCronJob( | ||||
|  | ||||
| 	logger := klog.FromContext(ctx) | ||||
| 	if cronJob.Spec.TimeZone != nil { | ||||
| 		timeZone := pointer.StringDeref(cronJob.Spec.TimeZone, "") | ||||
| 		timeZone := ptr.Deref(cronJob.Spec.TimeZone, "") | ||||
| 		if _, err := time.LoadLocation(timeZone); err != nil { | ||||
| 			logger.V(4).Info("Not starting job because timeZone is invalid", "cronjob", klog.KObj(cronJob), "timeZone", timeZone, "err", err) | ||||
| 			jm.recorder.Eventf(cronJob, corev1.EventTypeWarning, "UnknownTimeZone", "invalid timeZone: %q: %s", timeZone, err) | ||||
|   | ||||
| @@ -21,7 +21,6 @@ import ( | ||||
| 	"time" | ||||
|  | ||||
| 	"github.com/robfig/cron/v3" | ||||
| 	"k8s.io/utils/pointer" | ||||
|  | ||||
| 	batchv1 "k8s.io/api/batch/v1" | ||||
| 	corev1 "k8s.io/api/core/v1" | ||||
| @@ -32,6 +31,7 @@ import ( | ||||
| 	"k8s.io/client-go/tools/record" | ||||
| 	"k8s.io/klog/v2" | ||||
| 	"k8s.io/kubernetes/pkg/features" | ||||
| 	"k8s.io/utils/ptr" | ||||
| ) | ||||
|  | ||||
| // Utilities for dealing with Jobs and CronJobs and time. | ||||
| @@ -251,7 +251,7 @@ func getJobFromTemplate2(cj *batchv1.CronJob, scheduledTime time.Time) (*batchv1 | ||||
|  | ||||
| 	if utilfeature.DefaultFeatureGate.Enabled(features.CronJobsScheduledAnnotation) { | ||||
|  | ||||
| 		timeZoneLocation, err := time.LoadLocation(pointer.StringDeref(cj.Spec.TimeZone, "")) | ||||
| 		timeZoneLocation, err := time.LoadLocation(ptr.Deref(cj.Spec.TimeZone, "")) | ||||
| 		if err != nil { | ||||
| 			return nil, err | ||||
| 		} | ||||
|   | ||||
| @@ -33,7 +33,7 @@ import ( | ||||
| 	featuregatetesting "k8s.io/component-base/featuregate/testing" | ||||
| 	"k8s.io/klog/v2/ktesting" | ||||
| 	"k8s.io/kubernetes/pkg/features" | ||||
| 	"k8s.io/utils/pointer" | ||||
| 	"k8s.io/utils/ptr" | ||||
| ) | ||||
|  | ||||
| func TestGetJobFromTemplate2(t *testing.T) { | ||||
| @@ -141,7 +141,7 @@ func TestGetJobFromTemplate2(t *testing.T) { | ||||
| 			} | ||||
|  | ||||
| 			scheduledAnnotation := job.ObjectMeta.Annotations[batchv1.CronJobScheduledTimestampAnnotation] | ||||
| 			timeZoneLocation, err := time.LoadLocation(pointer.StringDeref(tt.timeZone, "")) | ||||
| 			timeZoneLocation, err := time.LoadLocation(ptr.Deref(tt.timeZone, "")) | ||||
| 			if err != nil { | ||||
| 				t.Errorf("Wrong timezone location") | ||||
| 			} | ||||
|   | ||||
| @@ -46,7 +46,7 @@ import ( | ||||
| 	"k8s.io/klog/v2" | ||||
| 	podutil "k8s.io/kubernetes/pkg/api/v1/pod" | ||||
| 	"k8s.io/kubernetes/pkg/controller/resourceclaim/metrics" | ||||
| 	"k8s.io/utils/pointer" | ||||
| 	"k8s.io/utils/ptr" | ||||
| ) | ||||
|  | ||||
| const ( | ||||
| @@ -722,7 +722,7 @@ func (ec *Controller) ensurePodSchedulingContext(ctx context.Context, pod *v1.Po | ||||
| 						Kind:       "Pod", | ||||
| 						Name:       pod.Name, | ||||
| 						UID:        pod.UID, | ||||
| 						Controller: pointer.Bool(true), | ||||
| 						Controller: ptr.To(true), | ||||
| 					}, | ||||
| 				}, | ||||
| 			}, | ||||
| @@ -951,7 +951,7 @@ func (ec *Controller) syncClaim(ctx context.Context, namespace, name string) err | ||||
|  | ||||
| func owningPod(claim *resourcev1alpha2.ResourceClaim) (string, types.UID) { | ||||
| 	for _, owner := range claim.OwnerReferences { | ||||
| 		if pointer.BoolDeref(owner.Controller, false) && | ||||
| 		if ptr.Deref(owner.Controller, false) && | ||||
| 			owner.APIVersion == "v1" && | ||||
| 			owner.Kind == "Pod" { | ||||
| 			return owner.Name, owner.UID | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 liyuerich
					liyuerich