diff --git a/contrib/completions/bash/kubectl b/contrib/completions/bash/kubectl index 346fc8639ff..1b21040322e 100644 --- a/contrib/completions/bash/kubectl +++ b/contrib/completions/bash/kubectl @@ -305,6 +305,8 @@ _kubectl_create() flags+=("-h") must_have_one_flag=() + must_have_one_flag+=("--filename=") + must_have_one_flag+=("-f") must_have_one_noun=() } @@ -329,6 +331,9 @@ _kubectl_update() flags+=("--patch=") must_have_one_flag=() + must_have_one_flag+=("--filename=") + must_have_one_flag+=("-f") + must_have_one_flag+=("--patch=") must_have_one_noun=() } @@ -445,6 +450,7 @@ _kubectl_resize() flags+=("--resource-version=") must_have_one_flag=() + must_have_one_flag+=("--replicas=") must_have_one_noun=() } @@ -470,6 +476,10 @@ _kubectl_exec() flags+=("-t") must_have_one_flag=() + must_have_one_flag+=("--container=") + must_have_one_flag+=("-c") + must_have_one_flag+=("--pod=") + must_have_one_flag+=("-p") must_have_one_noun=() } @@ -489,6 +499,8 @@ _kubectl_port-forward() two_word_flags+=("-p") must_have_one_flag=() + must_have_one_flag+=("--pod=") + must_have_one_flag+=("-p") must_have_one_noun=() } @@ -545,6 +557,7 @@ _kubectl_run-container() two_word_flags+=("-t") must_have_one_flag=() + must_have_one_flag+=("--image=") must_have_one_noun=() } @@ -608,6 +621,7 @@ _kubectl_expose() two_word_flags+=("-t") must_have_one_flag=() + must_have_one_flag+=("--port=") must_have_one_noun=() } diff --git a/pkg/kubectl/cmd/create.go b/pkg/kubectl/cmd/create.go index 4d769a31561..043b8ff2a94 100644 --- a/pkg/kubectl/cmd/create.go +++ b/pkg/kubectl/cmd/create.go @@ -54,6 +54,7 @@ func NewCmdCreate(f *cmdutil.Factory, out io.Writer) *cobra.Command { usage := "Filename, directory, or URL to file to use to create the resource" kubectl.AddJsonFilenameFlag(cmd, &filenames, usage) + cmd.MarkFlagRequired("filename") return cmd } diff --git a/pkg/kubectl/cmd/exec.go b/pkg/kubectl/cmd/exec.go index 194ec849df4..d41047a7946 100644 --- a/pkg/kubectl/cmd/exec.go +++ b/pkg/kubectl/cmd/exec.go @@ -50,8 +50,10 @@ func NewCmdExec(f *cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) * }, } cmd.Flags().StringP("pod", "p", "", "Pod name") + cmd.MarkFlagRequired("pod") // TODO support UID cmd.Flags().StringP("container", "c", "", "Container name") + cmd.MarkFlagRequired("container") cmd.Flags().BoolP("stdin", "i", false, "Pass stdin to the container") cmd.Flags().BoolP("tty", "t", false, "Stdin is a TTY") return cmd diff --git a/pkg/kubectl/cmd/expose.go b/pkg/kubectl/cmd/expose.go index cc2cf8bbee5..9e373ab9e96 100644 --- a/pkg/kubectl/cmd/expose.go +++ b/pkg/kubectl/cmd/expose.go @@ -57,6 +57,7 @@ func NewCmdExposeService(f *cmdutil.Factory, out io.Writer) *cobra.Command { cmd.Flags().String("generator", "service/v1", "The name of the API generator to use. Default is 'service/v1'.") cmd.Flags().String("protocol", "TCP", "The network protocol for the service to be created. Default is 'tcp'.") cmd.Flags().Int("port", -1, "The port that the service should serve on. Required.") + cmd.MarkFlagRequired("port") cmd.Flags().Bool("create-external-load-balancer", false, "If true, create an external load balancer for this service. Implementation is cloud provider dependent. Default is 'false'.") cmd.Flags().String("selector", "", "A label selector to use for this service. If empty (the default) infer the selector from the replication controller.") cmd.Flags().StringP("labels", "l", "", "Labels to apply to the service created by this call.") diff --git a/pkg/kubectl/cmd/portforward.go b/pkg/kubectl/cmd/portforward.go index c198b5788be..75e445b5792 100644 --- a/pkg/kubectl/cmd/portforward.go +++ b/pkg/kubectl/cmd/portforward.go @@ -54,6 +54,7 @@ func NewCmdPortForward(f *cmdutil.Factory) *cobra.Command { }, } cmd.Flags().StringP("pod", "p", "", "Pod name") + cmd.MarkFlagRequired("pod") // TODO support UID return cmd } diff --git a/pkg/kubectl/cmd/resize.go b/pkg/kubectl/cmd/resize.go index 6e1b9fa4347..5beefecc3fc 100644 --- a/pkg/kubectl/cmd/resize.go +++ b/pkg/kubectl/cmd/resize.go @@ -60,6 +60,7 @@ func NewCmdResize(f *cmdutil.Factory, out io.Writer) *cobra.Command { cmd.Flags().String("resource-version", "", "Precondition for resource version. Requires that the current resource version match this value in order to resize.") cmd.Flags().Int("current-replicas", -1, "Precondition for current size. Requires that the current size of the replication controller match this value in order to resize.") cmd.Flags().Int("replicas", -1, "The new desired number of replicas. Required.") + cmd.MarkFlagRequired("replicas") return cmd } diff --git a/pkg/kubectl/cmd/run.go b/pkg/kubectl/cmd/run.go index 37be3a939d2..b8d428cd2cf 100644 --- a/pkg/kubectl/cmd/run.go +++ b/pkg/kubectl/cmd/run.go @@ -56,6 +56,7 @@ func NewCmdRunContainer(f *cmdutil.Factory, out io.Writer) *cobra.Command { cmdutil.AddPrinterFlags(cmd) cmd.Flags().String("generator", "run-container/v1", "The name of the API generator to use. Default is 'run-container-controller/v1'.") cmd.Flags().String("image", "", "The image for the container to run.") + cmd.MarkFlagRequired("image") cmd.Flags().IntP("replicas", "r", 1, "Number of replicas to create for this container. Default is 1.") cmd.Flags().Bool("dry-run", false, "If true, only print the object that would be sent, without sending it.") cmd.Flags().String("overrides", "", "An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field.") diff --git a/pkg/kubectl/cmd/update.go b/pkg/kubectl/cmd/update.go index 18675e4a4b6..13e6dd3d847 100644 --- a/pkg/kubectl/cmd/update.go +++ b/pkg/kubectl/cmd/update.go @@ -56,7 +56,9 @@ func NewCmdUpdate(f *cmdutil.Factory, out io.Writer) *cobra.Command { } usage := "Filename, directory, or URL to file to use to update the resource." kubectl.AddJsonFilenameFlag(cmd, &filenames, usage) + cmd.MarkFlagRequired("filename") cmd.Flags().String("patch", "", "A JSON document to override the existing resource. The resource is downloaded, patched with the JSON, then updated.") + cmd.MarkFlagRequired("patch") return cmd }