From 29cd24b6ccc6ab5a2901e4fab4c1d0479459eb53 Mon Sep 17 00:00:00 2001 From: Mike Danese Date: Sat, 8 Feb 2020 12:30:21 -0500 Subject: [PATCH] generated: run refactor Kubernetes-commit: 25651408aeadf38c3df7ea8c760e7519fd37d625 --- pkg/cmd/autoscale/autoscale.go | 3 ++- pkg/cmd/create/create_clusterrole.go | 2 +- pkg/cmd/create/create_cronjob.go | 2 +- pkg/cmd/create/create_job.go | 2 +- pkg/cmd/create/create_role.go | 2 +- pkg/cmd/rollingupdate/rolling_updater.go | 8 ++++---- pkg/cmd/rollingupdate/rollingupdate.go | 2 +- pkg/drain/cordon.go | 5 +++-- pkg/polymorphichelpers/history_test.go | 2 +- pkg/polymorphichelpers/rollback.go | 6 +++--- 10 files changed, 18 insertions(+), 16 deletions(-) diff --git a/pkg/cmd/autoscale/autoscale.go b/pkg/cmd/autoscale/autoscale.go index ef22223b5..c9ff127ac 100644 --- a/pkg/cmd/autoscale/autoscale.go +++ b/pkg/cmd/autoscale/autoscale.go @@ -25,6 +25,7 @@ import ( autoscalingv1 "k8s.io/api/autoscaling/v1" "k8s.io/apimachinery/pkg/api/meta" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/cli-runtime/pkg/printers" "k8s.io/cli-runtime/pkg/resource" @@ -263,7 +264,7 @@ func (o *AutoscaleOptions) Run() error { return err } - actualHPA, err := o.HPAClient.HorizontalPodAutoscalers(o.namespace).Create(context.TODO(), hpa) + actualHPA, err := o.HPAClient.HorizontalPodAutoscalers(o.namespace).Create(context.TODO(), hpa, metav1.CreateOptions{}) if err != nil { return err } diff --git a/pkg/cmd/create/create_clusterrole.go b/pkg/cmd/create/create_clusterrole.go index 043012c3d..901af7e61 100644 --- a/pkg/cmd/create/create_clusterrole.go +++ b/pkg/cmd/create/create_clusterrole.go @@ -201,7 +201,7 @@ func (c *CreateClusterRoleOptions) RunCreateRole() error { // Create ClusterRole. if !c.DryRun { - clusterRole, err = c.Client.ClusterRoles().Create(context.TODO(), clusterRole) + clusterRole, err = c.Client.ClusterRoles().Create(context.TODO(), clusterRole, metav1.CreateOptions{}) if err != nil { return err } diff --git a/pkg/cmd/create/create_cronjob.go b/pkg/cmd/create/create_cronjob.go index adbdac483..e360a7367 100644 --- a/pkg/cmd/create/create_cronjob.go +++ b/pkg/cmd/create/create_cronjob.go @@ -165,7 +165,7 @@ func (o *CreateCronJobOptions) Run() error { if !o.DryRun { var err error - cronjob, err = o.Client.CronJobs(o.Namespace).Create(context.TODO(), cronjob) + cronjob, err = o.Client.CronJobs(o.Namespace).Create(context.TODO(), cronjob, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("failed to create cronjob: %v", err) } diff --git a/pkg/cmd/create/create_job.go b/pkg/cmd/create/create_job.go index 003cff474..83e640e45 100644 --- a/pkg/cmd/create/create_job.go +++ b/pkg/cmd/create/create_job.go @@ -193,7 +193,7 @@ func (o *CreateJobOptions) Run() error { } if !o.DryRun { var err error - job, err = o.Client.Jobs(o.Namespace).Create(context.TODO(), job) + job, err = o.Client.Jobs(o.Namespace).Create(context.TODO(), job, metav1.CreateOptions{}) if err != nil { return fmt.Errorf("failed to create job: %v", err) } diff --git a/pkg/cmd/create/create_role.go b/pkg/cmd/create/create_role.go index 8e540b548..cd07caf31 100644 --- a/pkg/cmd/create/create_role.go +++ b/pkg/cmd/create/create_role.go @@ -342,7 +342,7 @@ func (o *CreateRoleOptions) RunCreateRole() error { // Create role. if !o.DryRun { - role, err = o.Client.Roles(o.Namespace).Create(context.TODO(), role) + role, err = o.Client.Roles(o.Namespace).Create(context.TODO(), role, metav1.CreateOptions{}) if err != nil { return err } diff --git a/pkg/cmd/rollingupdate/rolling_updater.go b/pkg/cmd/rollingupdate/rolling_updater.go index 15f1af0cb..d955ac911 100644 --- a/pkg/cmd/rollingupdate/rolling_updater.go +++ b/pkg/cmd/rollingupdate/rolling_updater.go @@ -483,7 +483,7 @@ func (r *RollingUpdater) getOrCreateTargetControllerWithClient(controller *corev controller.Annotations[desiredReplicasAnnotation] = fmt.Sprintf("%d", valOrZero(controller.Spec.Replicas)) controller.Annotations[sourceIDAnnotation] = sourceID controller.Spec.Replicas = utilpointer.Int32Ptr(0) - newRc, err := r.rcClient.ReplicationControllers(r.ns).Create(context.TODO(), controller) + newRc, err := r.rcClient.ReplicationControllers(r.ns).Create(context.TODO(), controller, metav1.CreateOptions{}) return newRc, false, err } // Validate and use the existing controller. @@ -576,7 +576,7 @@ func Rename(c corev1client.ReplicationControllersGetter, rc *corev1.ReplicationC return err } // Then create the same RC with the new name. - _, err = c.ReplicationControllers(rc.Namespace).Create(context.TODO(), rc) + _, err = c.ReplicationControllers(rc.Namespace).Create(context.TODO(), rc, metav1.CreateOptions{}) return err } @@ -783,7 +783,7 @@ func updateRcWithRetries(rcClient corev1client.ReplicationControllersGetter, nam err := retry.RetryOnConflict(retry.DefaultBackoff, func() (e error) { // Apply the update, then attempt to push it to the apiserver. applyUpdate(rc) - if rc, e = rcClient.ReplicationControllers(namespace).Update(context.TODO(), rc); e == nil { + if rc, e = rcClient.ReplicationControllers(namespace).Update(context.TODO(), rc, metav1.UpdateOptions{}); e == nil { // rc contains the latest controller post update return } @@ -814,7 +814,7 @@ func updatePodWithRetries(podClient corev1client.PodsGetter, namespace string, p err := retry.RetryOnConflict(retry.DefaultBackoff, func() (e error) { // Apply the update, then attempt to push it to the apiserver. applyUpdate(pod) - if pod, e = podClient.Pods(namespace).Update(context.TODO(), pod); e == nil { + if pod, e = podClient.Pods(namespace).Update(context.TODO(), pod, metav1.UpdateOptions{}); e == nil { return } updateErr := e diff --git a/pkg/cmd/rollingupdate/rollingupdate.go b/pkg/cmd/rollingupdate/rollingupdate.go index f50afb461..899240fe2 100644 --- a/pkg/cmd/rollingupdate/rollingupdate.go +++ b/pkg/cmd/rollingupdate/rollingupdate.go @@ -432,7 +432,7 @@ func (o *RollingUpdateOptions) Run() error { if err != nil { return err } - coreClient.ReplicationControllers(config.NewRc.Namespace).Update(context.TODO(), config.NewRc) + coreClient.ReplicationControllers(config.NewRc.Namespace).Update(context.TODO(), config.NewRc, metav1.UpdateOptions{}) } err = updater.Update(config) if err != nil { diff --git a/pkg/drain/cordon.go b/pkg/drain/cordon.go index 7ce6bc132..f7bb7d4d4 100644 --- a/pkg/drain/cordon.go +++ b/pkg/drain/cordon.go @@ -21,6 +21,7 @@ import ( "fmt" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" @@ -88,9 +89,9 @@ func (c *CordonHelper) PatchOrReplace(clientset kubernetes.Interface) (error, er patchBytes, patchErr := strategicpatch.CreateTwoWayMergePatch(oldData, newData, c.node) if patchErr == nil { - _, err = client.Patch(context.TODO(), c.node.Name, types.StrategicMergePatchType, patchBytes) + _, err = client.Patch(context.TODO(), c.node.Name, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}) } else { - _, err = client.Update(context.TODO(), c.node) + _, err = client.Update(context.TODO(), c.node, metav1.UpdateOptions{}) } return err, patchErr } diff --git a/pkg/polymorphichelpers/history_test.go b/pkg/polymorphichelpers/history_test.go index 45bb569e0..8b2af5704 100644 --- a/pkg/polymorphichelpers/history_test.go +++ b/pkg/polymorphichelpers/history_test.go @@ -85,7 +85,7 @@ func TestViewHistory(t *testing.T) { ) fakeClientSet := fake.NewSimpleClientset(ssStub) - _, err := fakeClientSet.AppsV1().ControllerRevisions("default").Create(context.TODO(), ssStub1) + _, err := fakeClientSet.AppsV1().ControllerRevisions("default").Create(context.TODO(), ssStub1, metav1.CreateOptions{}) if err != nil { t.Fatalf("create controllerRevisions error %v occurred ", err) } diff --git a/pkg/polymorphichelpers/rollback.go b/pkg/polymorphichelpers/rollback.go index 4ea1dc5ce..bcead995b 100644 --- a/pkg/polymorphichelpers/rollback.go +++ b/pkg/polymorphichelpers/rollback.go @@ -154,7 +154,7 @@ func (r *DeploymentRollbacker) Rollback(obj runtime.Object, updatedAnnotations m } // Restore revision - if _, err = r.c.AppsV1().Deployments(namespace).Patch(context.TODO(), name, patchType, patch); err != nil { + if _, err = r.c.AppsV1().Deployments(namespace).Patch(context.TODO(), name, patchType, patch, metav1.PatchOptions{}); err != nil { return "", fmt.Errorf("failed restoring revision %d: %v", toRevision, err) } return rollbackSuccess, nil @@ -294,7 +294,7 @@ func (r *DaemonSetRollbacker) Rollback(obj runtime.Object, updatedAnnotations ma } // Restore revision - if _, err = r.c.AppsV1().DaemonSets(accessor.GetNamespace()).Patch(context.TODO(), accessor.GetName(), types.StrategicMergePatchType, toHistory.Data.Raw); err != nil { + if _, err = r.c.AppsV1().DaemonSets(accessor.GetNamespace()).Patch(context.TODO(), accessor.GetName(), types.StrategicMergePatchType, toHistory.Data.Raw, metav1.PatchOptions{}); err != nil { return "", fmt.Errorf("failed restoring revision %d: %v", toRevision, err) } @@ -381,7 +381,7 @@ func (r *StatefulSetRollbacker) Rollback(obj runtime.Object, updatedAnnotations } // Restore revision - if _, err = r.c.AppsV1().StatefulSets(sts.Namespace).Patch(context.TODO(), sts.Name, types.StrategicMergePatchType, toHistory.Data.Raw); err != nil { + if _, err = r.c.AppsV1().StatefulSets(sts.Namespace).Patch(context.TODO(), sts.Name, types.StrategicMergePatchType, toHistory.Data.Raw, metav1.PatchOptions{}); err != nil { return "", fmt.Errorf("failed restoring revision %d: %v", toRevision, err) }