From cda7f95d4621439e55ece30bc13da7bf6fe1a355 Mon Sep 17 00:00:00 2001 From: Di Xu Date: Sat, 24 Feb 2018 16:37:19 +0800 Subject: [PATCH] flag value bindings for kubectl label/patch/taint/top commands --- pkg/kubectl/cmd/label.go | 2 +- pkg/kubectl/cmd/patch.go | 2 +- pkg/kubectl/cmd/taint.go | 6 +++--- pkg/kubectl/cmd/top.go | 3 --- pkg/kubectl/cmd/top_node.go | 2 +- pkg/kubectl/cmd/top_pod.go | 6 +++--- 6 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/kubectl/cmd/label.go b/pkg/kubectl/cmd/label.go index 4e1a9c9495..7784f9f6f0 100644 --- a/pkg/kubectl/cmd/label.go +++ b/pkg/kubectl/cmd/label.go @@ -118,7 +118,7 @@ func NewCmdLabel(f cmdutil.Factory, out io.Writer) *cobra.Command { ArgAliases: kubectl.ResourceAliases(validArgs), } cmdutil.AddPrinterFlags(cmd) - cmd.Flags().BoolVar(&options.overwrite, "overwrite", false, "If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels.") + cmd.Flags().BoolVar(&options.overwrite, "overwrite", options.overwrite, "If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels.") cmd.Flags().BoolVar(&options.list, "list", options.list, "If true, display the labels for a given resource.") cmd.Flags().BoolVar(&options.local, "local", options.local, "If true, label will NOT contact api-server but run locally.") cmd.Flags().StringVarP(&options.selector, "selector", "l", options.selector, "Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).") diff --git a/pkg/kubectl/cmd/patch.go b/pkg/kubectl/cmd/patch.go index 26e3b27c9d..fd0b3adebb 100644 --- a/pkg/kubectl/cmd/patch.go +++ b/pkg/kubectl/cmd/patch.go @@ -107,7 +107,7 @@ func NewCmdPatch(f cmdutil.Factory, out io.Writer) *cobra.Command { usage := "identifying the resource to update" cmdutil.AddFilenameOptionFlags(cmd, &options.FilenameOptions, usage) - cmd.Flags().BoolVar(&options.Local, "local", false, "If true, patch will operate on the content of the file, not the server-side resource.") + cmd.Flags().BoolVar(&options.Local, "local", options.Local, "If true, patch will operate on the content of the file, not the server-side resource.") return cmd } diff --git a/pkg/kubectl/cmd/taint.go b/pkg/kubectl/cmd/taint.go index 9e507b517d..e48d301d9e 100644 --- a/pkg/kubectl/cmd/taint.go +++ b/pkg/kubectl/cmd/taint.go @@ -108,9 +108,9 @@ func NewCmdTaint(f cmdutil.Factory, out io.Writer) *cobra.Command { cmdutil.AddPrinterFlags(cmd) cmdutil.AddInclude3rdPartyFlags(cmd) - cmd.Flags().StringVarP(&options.selector, "selector", "l", "", "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") - cmd.Flags().BoolVar(&options.overwrite, "overwrite", false, "If true, allow taints to be overwritten, otherwise reject taint updates that overwrite existing taints.") - cmd.Flags().BoolVar(&options.all, "all", false, "Select all nodes in the cluster") + cmd.Flags().StringVarP(&options.selector, "selector", "l", options.selector, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") + cmd.Flags().BoolVar(&options.overwrite, "overwrite", options.overwrite, "If true, allow taints to be overwritten, otherwise reject taint updates that overwrite existing taints.") + cmd.Flags().BoolVar(&options.all, "all", options.all, "Select all nodes in the cluster") return cmd } diff --git a/pkg/kubectl/cmd/top.go b/pkg/kubectl/cmd/top.go index 63ca2bcc9d..608c0ae7c5 100644 --- a/pkg/kubectl/cmd/top.go +++ b/pkg/kubectl/cmd/top.go @@ -28,9 +28,6 @@ import ( "k8s.io/kubernetes/pkg/kubectl/cmd/templates" ) -// TopOptions contains all the options for running the top cli command. -type TopOptions struct{} - var ( supportedMetricsAPIVersions = []string{ "v1beta1", diff --git a/pkg/kubectl/cmd/top_node.go b/pkg/kubectl/cmd/top_node.go index 293f81a6bd..624be6633a 100644 --- a/pkg/kubectl/cmd/top_node.go +++ b/pkg/kubectl/cmd/top_node.go @@ -113,7 +113,7 @@ func NewCmdTopNode(f cmdutil.Factory, options *TopNodeOptions, out io.Writer) *c }, Aliases: []string{"nodes", "no"}, } - cmd.Flags().StringVarP(&options.Selector, "selector", "l", "", "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") + cmd.Flags().StringVarP(&options.Selector, "selector", "l", options.Selector, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") options.HeapsterOptions.Bind(cmd.Flags()) return cmd } diff --git a/pkg/kubectl/cmd/top_pod.go b/pkg/kubectl/cmd/top_pod.go index 75f7906dfe..71bd8df2cb 100644 --- a/pkg/kubectl/cmd/top_pod.go +++ b/pkg/kubectl/cmd/top_pod.go @@ -102,9 +102,9 @@ func NewCmdTopPod(f cmdutil.Factory, options *TopPodOptions, out io.Writer) *cob }, Aliases: []string{"pods", "po"}, } - cmd.Flags().StringVarP(&options.Selector, "selector", "l", "", "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") - cmd.Flags().BoolVar(&options.PrintContainers, "containers", false, "If present, print usage of containers within a pod.") - cmd.Flags().BoolVar(&options.AllNamespaces, "all-namespaces", false, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.") + cmd.Flags().StringVarP(&options.Selector, "selector", "l", options.Selector, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") + cmd.Flags().BoolVar(&options.PrintContainers, "containers", options.PrintContainers, "If present, print usage of containers within a pod.") + cmd.Flags().BoolVar(&options.AllNamespaces, "all-namespaces", options.AllNamespaces, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.") options.HeapsterOptions.Bind(cmd.Flags()) return cmd }