generated: run refactor
Kubernetes-commit: 25651408aeadf38c3df7ea8c760e7519fd37d625
This commit is contained in:
parent
a9e8eb5139
commit
29cd24b6cc
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue