generated: run refactor

Kubernetes-commit: 3aa59f7f3077642592dc8a864fcef8ba98699894
This commit is contained in:
Mike Danese 2020-02-07 18:16:47 -08:00 committed by Kubernetes Publisher
parent 81e6fe3b90
commit 297436d318
2 changed files with 7 additions and 5 deletions

View File

@ -17,6 +17,7 @@ limitations under the License.
package main package main
import ( import (
"context"
"fmt" "fmt"
"time" "time"
@ -273,7 +274,7 @@ func (c *Controller) syncHandler(key string) error {
deployment, err := c.deploymentsLister.Deployments(foo.Namespace).Get(deploymentName) deployment, err := c.deploymentsLister.Deployments(foo.Namespace).Get(deploymentName)
// If the resource doesn't exist, we'll create it // If the resource doesn't exist, we'll create it
if errors.IsNotFound(err) { if errors.IsNotFound(err) {
deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Create(newDeployment(foo)) deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Create(context.TODO(), newDeployment(foo))
} }
// If an error occurs during Get/Create, we'll requeue the item so we can // If an error occurs during Get/Create, we'll requeue the item so we can
@ -296,7 +297,7 @@ func (c *Controller) syncHandler(key string) error {
// should update the Deployment resource. // should update the Deployment resource.
if foo.Spec.Replicas != nil && *foo.Spec.Replicas != *deployment.Spec.Replicas { if foo.Spec.Replicas != nil && *foo.Spec.Replicas != *deployment.Spec.Replicas {
klog.V(4).Infof("Foo %s replicas: %d, deployment replicas: %d", name, *foo.Spec.Replicas, *deployment.Spec.Replicas) klog.V(4).Infof("Foo %s replicas: %d, deployment replicas: %d", name, *foo.Spec.Replicas, *deployment.Spec.Replicas)
deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Update(newDeployment(foo)) deployment, err = c.kubeclientset.AppsV1().Deployments(foo.Namespace).Update(context.TODO(), newDeployment(foo))
} }
// If an error occurs during Update, we'll requeue the item so we can // If an error occurs during Update, we'll requeue the item so we can
@ -327,7 +328,7 @@ func (c *Controller) updateFooStatus(foo *samplev1alpha1.Foo, deployment *appsv1
// we must use Update instead of UpdateStatus to update the Status block of the Foo resource. // we must use Update instead of UpdateStatus to update the Status block of the Foo resource.
// UpdateStatus will not allow changes to the Spec of the resource, // UpdateStatus will not allow changes to the Spec of the resource,
// which is ideal for ensuring nothing other than resource status has been updated. // which is ideal for ensuring nothing other than resource status has been updated.
_, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).Update(fooCopy) _, err := c.sampleclientset.SamplecontrollerV1alpha1().Foos(foo.Namespace).Update(context.TODO(), fooCopy)
return err return err
} }

View File

@ -19,6 +19,7 @@ limitations under the License.
package v1alpha1 package v1alpha1
import ( import (
"context"
time "time" time "time"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -61,13 +62,13 @@ func NewFilteredFooInformer(client versioned.Interface, namespace string, resync
if tweakListOptions != nil { if tweakListOptions != nil {
tweakListOptions(&options) tweakListOptions(&options)
} }
return client.SamplecontrollerV1alpha1().Foos(namespace).List(options) return client.SamplecontrollerV1alpha1().Foos(namespace).List(context.TODO(), options)
}, },
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil { if tweakListOptions != nil {
tweakListOptions(&options) tweakListOptions(&options)
} }
return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(options) return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(context.TODO(), options)
}, },
}, },
&samplecontrollerv1alpha1.Foo{}, &samplecontrollerv1alpha1.Foo{},