diff --git a/controller.go b/controller.go index b3447505..4b8d29f0 100644 --- a/controller.go +++ b/controller.go @@ -17,6 +17,7 @@ limitations under the License. package main import ( + "context" "fmt" "time" @@ -273,7 +274,7 @@ func (c *Controller) syncHandler(key string) error { deployment, err := c.deploymentsLister.Deployments(foo.Namespace).Get(deploymentName) // If the resource doesn't exist, we'll create it 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 @@ -296,7 +297,7 @@ func (c *Controller) syncHandler(key string) error { // should update the Deployment resource. 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) - 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 @@ -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. // UpdateStatus will not allow changes to the Spec of the resource, // 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 } diff --git a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go index 21fda895..44f3487c 100644 --- a/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go +++ b/pkg/generated/informers/externalversions/samplecontroller/v1alpha1/foo.go @@ -19,6 +19,7 @@ limitations under the License. package v1alpha1 import ( + "context" time "time" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -61,13 +62,13 @@ func NewFilteredFooInformer(client versioned.Interface, namespace string, resync if tweakListOptions != nil { 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) { if tweakListOptions != nil { tweakListOptions(&options) } - return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(options) + return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(context.TODO(), options) }, }, &samplecontrollerv1alpha1.Foo{},