diff --git a/pkg/cmd/apply/prune.go b/pkg/cmd/apply/prune.go index 399616edd..487837056 100644 --- a/pkg/cmd/apply/prune.go +++ b/pkg/cmd/apply/prune.go @@ -17,6 +17,7 @@ limitations under the License. package apply import ( + "context" "fmt" "io" "strings" @@ -97,7 +98,7 @@ func (p *pruner) pruneAll(o *ApplyOptions) error { func (p *pruner) prune(namespace string, mapping *meta.RESTMapping) error { objList, err := p.dynamicClient.Resource(mapping.Resource). Namespace(namespace). - List(metav1.ListOptions{ + List(context.TODO(), metav1.ListOptions{ LabelSelector: p.labelSelector, FieldSelector: p.fieldSelector, }) @@ -157,7 +158,7 @@ func runDelete(namespace, name string, mapping *meta.RESTMapping, c dynamic.Inte policy = metav1.DeletePropagationOrphan } options.PropagationPolicy = &policy - return c.Resource(mapping.Resource).Namespace(namespace).Delete(name, options) + return c.Resource(mapping.Resource).Namespace(namespace).Delete(context.TODO(), name, options) } type pruneResource struct { diff --git a/pkg/cmd/create/create.go b/pkg/cmd/create/create.go index 2ed639cda..71a0dc401 100644 --- a/pkg/cmd/create/create.go +++ b/pkg/cmd/create/create.go @@ -17,6 +17,7 @@ limitations under the License. package create import ( + "context" "fmt" "io" "net/url" @@ -451,7 +452,7 @@ func (o *CreateSubcommandOptions) Run() error { } createOptions.DryRun = []string{metav1.DryRunAll} } - actualObject, err := o.DynamicClient.Resource(mapping.Resource).Namespace(o.Namespace).Create(asUnstructured, createOptions) + actualObject, err := o.DynamicClient.Resource(mapping.Resource).Namespace(o.Namespace).Create(context.TODO(), asUnstructured, createOptions) if err != nil { return err } diff --git a/pkg/cmd/rollout/rollout_status.go b/pkg/cmd/rollout/rollout_status.go index a44aea40b..23f07253a 100644 --- a/pkg/cmd/rollout/rollout_status.go +++ b/pkg/cmd/rollout/rollout_status.go @@ -192,11 +192,11 @@ func (o *RolloutStatusOptions) Run() error { lw := &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { options.FieldSelector = fieldSelector - return o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).List(options) + return o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).List(context.TODO(), options) }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { options.FieldSelector = fieldSelector - return o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Watch(options) + return o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Watch(context.TODO(), options) }, } diff --git a/pkg/cmd/wait/wait.go b/pkg/cmd/wait/wait.go index 3a0840155..2bb0db352 100644 --- a/pkg/cmd/wait/wait.go +++ b/pkg/cmd/wait/wait.go @@ -263,7 +263,7 @@ func IsDeleted(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error nameSelector := fields.OneTermEqualSelector("metadata.name", info.Name).String() // List with a name field selector to get the current resourceVersion to watch from (not the object's resourceVersion) - gottenObjList, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).List(metav1.ListOptions{FieldSelector: nameSelector}) + gottenObjList, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).List(context.TODO(), metav1.ListOptions{FieldSelector: nameSelector}) if apierrors.IsNotFound(err) { return info.Object, true, nil } @@ -289,7 +289,7 @@ func IsDeleted(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error watchOptions := metav1.ListOptions{} watchOptions.FieldSelector = nameSelector watchOptions.ResourceVersion = gottenObjList.GetResourceVersion() - objWatch, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Watch(watchOptions) + objWatch, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Watch(context.TODO(), watchOptions) if err != nil { return gottenObj, false, err } @@ -361,7 +361,7 @@ func (w ConditionalWait) IsConditionMet(info *resource.Info, o *WaitOptions) (ru var gottenObj *unstructured.Unstructured // List with a name field selector to get the current resourceVersion to watch from (not the object's resourceVersion) - gottenObjList, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).List(metav1.ListOptions{FieldSelector: nameSelector}) + gottenObjList, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).List(context.TODO(), metav1.ListOptions{FieldSelector: nameSelector}) resourceVersion := "" switch { @@ -384,7 +384,7 @@ func (w ConditionalWait) IsConditionMet(info *resource.Info, o *WaitOptions) (ru watchOptions := metav1.ListOptions{} watchOptions.FieldSelector = nameSelector watchOptions.ResourceVersion = resourceVersion - objWatch, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Watch(watchOptions) + objWatch, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Watch(context.TODO(), watchOptions) if err != nil { return gottenObj, false, err } diff --git a/pkg/describe/describe.go b/pkg/describe/describe.go index 9667259b3..f72b1bb65 100644 --- a/pkg/describe/describe.go +++ b/pkg/describe/describe.go @@ -247,7 +247,7 @@ type genericDescriber struct { } func (g *genericDescriber) Describe(namespace, name string, describerSettings DescriberSettings) (output string, err error) { - obj, err := g.dynamic.Resource(g.mapping.Resource).Namespace(namespace).Get(name, metav1.GetOptions{}) + obj, err := g.dynamic.Resource(g.mapping.Resource).Namespace(namespace).Get(context.TODO(), name, metav1.GetOptions{}) if err != nil { return "", err }