From ad26db7f459e2f10e0155c2e713de74a1afcd1d0 Mon Sep 17 00:00:00 2001 From: hurf Date: Tue, 24 Nov 2015 09:53:54 +0800 Subject: [PATCH] Annotate support label allow "kubectl annotate pods -l app=nginx" --- contrib/completions/bash/kubectl | 2 ++ docs/man/man1/kubectl-annotate.1 | 4 ++++ docs/user-guide/kubectl/kubectl_annotate.md | 3 ++- pkg/kubectl/cmd/annotate.go | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl index 124ed7367c..8dd90883d0 100644 --- a/contrib/completions/bash/kubectl +++ b/contrib/completions/bash/kubectl @@ -981,6 +981,8 @@ _kubectl_annotate() flags+=("--output-version=") flags+=("--overwrite") flags+=("--resource-version=") + flags+=("--selector=") + two_word_flags+=("-l") flags+=("--show-all") flags+=("-a") flags+=("--sort-by=") diff --git a/docs/man/man1/kubectl-annotate.1 b/docs/man/man1/kubectl-annotate.1 index a0dac664a6..30245daf9e 100644 --- a/docs/man/man1/kubectl-annotate.1 +++ b/docs/man/man1/kubectl-annotate.1 @@ -59,6 +59,10 @@ horizontalpodautoscalers (hpa), resourcequotas (quota) or secrets. \fB\-\-resource\-version\fP="" 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. +.PP +\fB\-l\fP, \fB\-\-selector\fP="" + Selector (label query) to filter on + .PP \fB\-a\fP, \fB\-\-show\-all\fP=false When printing, show all resources (default hide terminated pods.) diff --git a/docs/user-guide/kubectl/kubectl_annotate.md b/docs/user-guide/kubectl/kubectl_annotate.md index 26e92a4e42..c30f732182 100644 --- a/docs/user-guide/kubectl/kubectl_annotate.md +++ b/docs/user-guide/kubectl/kubectl_annotate.md @@ -88,6 +88,7 @@ $ kubectl annotate pods foo description- --output-version="": Output the formatted object with the given version (default api-version). --overwrite[=false]: If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations. --resource-version="": 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. + -l, --selector="": Selector (label query) to filter on -a, --show-all[=false]: When printing, show all resources (default hide terminated pods.) --sort-by="": If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. 'ObjectMeta.Name'). The field in the API resource specified by this JSONPath expression must be an integer or a string. --template="": Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. @@ -125,7 +126,7 @@ $ kubectl annotate pods foo description- * [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager -###### Auto generated by spf13/cobra on 19-Nov-2015 +###### Auto generated by spf13/cobra on 24-Nov-2015 [![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_annotate.md?pixel)]() diff --git a/pkg/kubectl/cmd/annotate.go b/pkg/kubectl/cmd/annotate.go index ddcf8fd0dd..3f82db4ff5 100644 --- a/pkg/kubectl/cmd/annotate.go +++ b/pkg/kubectl/cmd/annotate.go @@ -39,6 +39,7 @@ type AnnotateOptions struct { removeAnnotations []string builder *resource.Builder filenames []string + selector string overwrite bool all bool @@ -103,6 +104,7 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command { }, } cmdutil.AddPrinterFlags(cmd) + cmd.Flags().StringVarP(&options.selector, "selector", "l", "", "Selector (label query) to filter on") cmd.Flags().BoolVar(&options.overwrite, "overwrite", false, "If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations.") cmd.Flags().BoolVar(&options.all, "all", false, "select all resources in the namespace of the specified resource types") cmd.Flags().StringVar(&options.resourceVersion, "resource-version", "", "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.") @@ -153,6 +155,7 @@ func (o *AnnotateOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra ContinueOnError(). NamespaceParam(namespace).DefaultNamespace(). FilenameParam(enforceNamespace, o.filenames...). + SelectorParam(o.selector). ResourceTypeOrNameArgs(o.all, o.resources...). Flatten(). Latest()