From f1feb4b0d51815f70cca34c4b6e8840815f5ad44 Mon Sep 17 00:00:00 2001 From: David Eads Date: Mon, 26 Apr 2021 11:13:01 -0400 Subject: [PATCH] add --all-namespaces to kubectl annotate,label Kubernetes-commit: ad0cff7b61515e481098a1dfbe785066d655da97 --- pkg/cmd/annotate/annotate.go | 3 +++ pkg/cmd/label/label.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/cmd/annotate/annotate.go b/pkg/cmd/annotate/annotate.go index 1e7a7f8d..00fe8423 100644 --- a/pkg/cmd/annotate/annotate.go +++ b/pkg/cmd/annotate/annotate.go @@ -59,6 +59,7 @@ type AnnotateOptions struct { dryRunVerifier *resource.DryRunVerifier fieldManager string all bool + allNamespaces bool resourceVersion string selector string fieldSelector string @@ -150,6 +151,7 @@ func NewCmdAnnotate(parent string, f cmdutil.Factory, ioStreams genericclioption cmd.Flags().StringVarP(&o.selector, "selector", "l", o.selector, "Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).") cmd.Flags().StringVar(&o.fieldSelector, "field-selector", o.fieldSelector, "Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.") cmd.Flags().BoolVar(&o.all, "all", o.all, "Select all resources, including uninitialized ones, in the namespace of the specified resource types.") + cmd.Flags().BoolVarP(&o.allNamespaces, "all-namespaces", "A", o.allNamespaces, "If true, check the specified action in all namespaces.") cmd.Flags().StringVar(&o.resourceVersion, "resource-version", o.resourceVersion, i18n.T("If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.")) usage := "identifying the resource to update the annotation" cmdutil.AddFilenameOptionFlags(cmd, &o.FilenameOptions, usage) @@ -257,6 +259,7 @@ func (o AnnotateOptions) RunAnnotate() error { if !o.local { b = b.LabelSelectorParam(o.selector). FieldSelectorParam(o.fieldSelector). + AllNamespaces(o.allNamespaces). ResourceTypeOrNameArgs(o.all, o.resources...). Latest() } diff --git a/pkg/cmd/label/label.go b/pkg/cmd/label/label.go index b3de4f24..430ac7b5 100644 --- a/pkg/cmd/label/label.go +++ b/pkg/cmd/label/label.go @@ -58,6 +58,7 @@ type LabelOptions struct { local bool dryRunStrategy cmdutil.DryRunStrategy all bool + allNamespaces bool resourceVersion string selector string fieldSelector string @@ -147,6 +148,7 @@ func NewCmdLabel(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobr cmd.Flags().StringVarP(&o.selector, "selector", "l", o.selector, "Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).") cmd.Flags().StringVar(&o.fieldSelector, "field-selector", o.fieldSelector, "Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.") cmd.Flags().BoolVar(&o.all, "all", o.all, "Select all resources, including uninitialized ones, in the namespace of the specified resource types") + cmd.Flags().BoolVarP(&o.allNamespaces, "all-namespaces", "A", o.allNamespaces, "If true, check the specified action in all namespaces.") cmd.Flags().StringVar(&o.resourceVersion, "resource-version", o.resourceVersion, i18n.T("If non-empty, the labels update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.")) usage := "identifying the resource to update the labels" cmdutil.AddFilenameOptionFlags(cmd, &o.FilenameOptions, usage) @@ -249,6 +251,7 @@ func (o *LabelOptions) RunLabel() error { if !o.local { b = b.LabelSelectorParam(o.selector). FieldSelectorParam(o.fieldSelector). + AllNamespaces(o.allNamespaces). ResourceTypeOrNameArgs(o.all, o.resources...). Latest() }