Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused parameters and flags in Annotate command #13131

Merged
merged 1 commit into from
Sep 1, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions contrib/completions/bash/kubectl
Original file line number Diff line number Diff line change
Expand Up @@ -854,17 +854,8 @@ _kubectl_annotate()
flags_completion+=("__handle_filename_extension_flag json|yaml|yml")
flags+=("--help")
flags+=("-h")
flags+=("--no-headers")
flags+=("--output=")
two_word_flags+=("-o")
flags+=("--output-version=")
flags+=("--overwrite")
flags+=("--resource-version=")
flags+=("--show-all")
flags+=("-a")
flags+=("--sort-by=")
flags+=("--template=")
two_word_flags+=("-t")

must_have_one_flag=()
must_have_one_noun=()
Expand Down
26 changes: 0 additions & 26 deletions docs/man/man1/kubectl-annotate.1
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,6 @@ resourcequotas (quota) or secrets.
\fB\-h\fP, \fB\-\-help\fP=false
help for annotate

.PP
\fB\-\-no\-headers\fP=false
When using the default output, don't print headers.

.PP
\fB\-o\fP, \fB\-\-output\fP=""
Output format. One of: json|yaml|template|templatefile|wide|jsonpath|name.

.PP
\fB\-\-output\-version\fP=""
Output the formatted object with the given version (default api\-version).

.PP
\fB\-\-overwrite\fP=false
If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations.
Expand All @@ -61,20 +49,6 @@ 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\-a\fP, \fB\-\-show\-all\fP=false
When printing, show all resources (default hide terminated pods.)

.PP
\fB\-\-sort\-by\fP=""
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.

.PP
\fB\-t\fP, \fB\-\-template\fP=""
Template string or path to template file to use when \-o=template, \-o=templatefile or \-o=jsonpath. The template format is golang templates [
\[la]http://golang.org/pkg/text/template/#pkg-overview\[ra]]. The jsonpath template is composed of jsonpath expressions enclosed by {} [
\[la]http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md\[ra]]


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
Expand Down
8 changes: 1 addition & 7 deletions docs/user-guide/kubectl/kubectl_annotate.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,8 @@ $ kubectl annotate pods foo description-
--all[=false]: select all resources in the namespace of the specified resource types
-f, --filename=[]: Filename, directory, or URL to a file identifying the resource to update the annotation
-h, --help[=false]: help for annotate
--no-headers[=false]: When using the default output, don't print headers.
-o, --output="": Output format. One of: json|yaml|template|templatefile|wide|jsonpath|name.
--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.
-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=template, -o=templatefile or -o=jsonpath. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. The jsonpath template is composed of jsonpath expressions enclosed by {} [http://releases.k8s.io/HEAD/docs/user-guide/jsonpath.md]
```

### Options inherited from parent commands
Expand Down Expand Up @@ -126,7 +120,7 @@ $ kubectl annotate pods foo description-

* [kubectl](kubectl.md) - kubectl controls the Kubernetes cluster manager

###### Auto generated by spf13/cobra at 2015-08-25 11:50:09.184436452 +0000 UTC
###### Auto generated by spf13/cobra at 2015-08-27 02:40:25.687121316 +0000 UTC

<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->
[![Analytics](https://kubernetes-site.appspot.com/UA-36037335-10/GitHub/docs/user-guide/kubectl/kubectl_annotate.md?pixel)]()
Expand Down
6 changes: 2 additions & 4 deletions pkg/kubectl/cmd/annotation.go → pkg/kubectl/cmd/annotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (

// AnnotateOptions have the data required to perform the annotate operation
type AnnotateOptions struct {
out io.Writer
resources []string
newAnnotations map[string]string
removeAnnotations []string
Expand Down Expand Up @@ -87,7 +86,7 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
Example: annotate_example,
Run: func(cmd *cobra.Command, args []string) {
options.filenames = cmdutil.GetFlagStringSlice(cmd, "filename")
if err := options.Complete(f, args, out); err != nil {
if err := options.Complete(f, args); err != nil {
cmdutil.CheckErr(err)
}
if err := options.Validate(args); err != nil {
Expand All @@ -98,7 +97,6 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}
},
}
cmdutil.AddPrinterFlags(cmd)
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.")
Expand All @@ -108,7 +106,7 @@ func NewCmdAnnotate(f *cmdutil.Factory, out io.Writer) *cobra.Command {
}

// Complete adapts from the command line args and factory to the data required.
func (o *AnnotateOptions) Complete(f *cmdutil.Factory, args []string, out io.Writer) (err error) {
func (o *AnnotateOptions) Complete(f *cmdutil.Factory, args []string) (err error) {
namespace, enforceNamespace, err := f.DefaultNamespace()
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func TestAnnotateErrors(t *testing.T) {
cmd.Flags().Set(k, v)
}
options := &AnnotateOptions{}
err := options.Complete(f, testCase.args, buf)
err := options.Complete(f, testCase.args)
if !testCase.errFn(err) {
t.Errorf("%s: unexpected error: %v", k, err)
continue
Expand Down Expand Up @@ -448,11 +448,10 @@ func TestAnnotateObject(t *testing.T) {
}
tf.Namespace = "test"
tf.ClientConfig = &client.Config{Version: testapi.Version()}
buf := bytes.NewBuffer([]byte{})

options := &AnnotateOptions{}
args := []string{"pods/foo", "a=b", "c-"}
if err := options.Complete(f, args, buf); err != nil {
if err := options.Complete(f, args); err != nil {
t.Fatalf("unexpected error: %v", err)
}
if err := options.Validate(args); err != nil {
Expand Down Expand Up @@ -496,12 +495,11 @@ func TestAnnotateObjectFromFile(t *testing.T) {
}
tf.Namespace = "test"
tf.ClientConfig = &client.Config{Version: testapi.Version()}
buf := bytes.NewBuffer([]byte{})

options := &AnnotateOptions{}
options.filenames = []string{"../../../examples/cassandra/cassandra.yaml"}
args := []string{"a=b", "c-"}
if err := options.Complete(f, args, buf); err != nil {
if err := options.Complete(f, args); err != nil {
t.Fatalf("unexpected error: %v", err)
}
if err := options.Validate(args); err != nil {
Expand Down Expand Up @@ -547,12 +545,11 @@ func TestAnnotateMultipleObjects(t *testing.T) {
}
tf.Namespace = "test"
tf.ClientConfig = &client.Config{Version: testapi.Version()}
buf := bytes.NewBuffer([]byte{})

options := &AnnotateOptions{}
options.all = true
args := []string{"pods", "a=b", "c-"}
if err := options.Complete(f, args, buf); err != nil {
if err := options.Complete(f, args); err != nil {
t.Fatalf("unexpected error: %v", err)
}
if err := options.Validate(args); err != nil {
Expand Down