Unverified Commit ce227b06 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #66558 from quasoft/depr-pod-flag

Automatic merge from submit-queue (batch tested with PRs 66593, 66727, 66558). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Mark --pod/-p flag of kubectl exec command as deprecated **What this PR does / why we need it**: Marks the `--pod` (`-p` shorthand) flag of kubectl `exec` command as deprecated. Hides the flag from the help menu, but shows a message when command is executed with this flag. **Which issue this PR fixes**: Fixes: https://github.com/kubernetes/kubectl/issues/104 This is a remake of PR https://github.com/kubernetes/kubernetes/pull/54629. **Release note**: ```release-note Flag --pod (-p shorthand) of kubectl exec command marked as deprecated ```
parents 5bc45727 75804c35
...@@ -85,6 +85,7 @@ func NewCmdExec(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C ...@@ -85,6 +85,7 @@ func NewCmdExec(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.C
}, },
} }
cmd.Flags().StringVarP(&options.PodName, "pod", "p", options.PodName, "Pod name") cmd.Flags().StringVarP(&options.PodName, "pod", "p", options.PodName, "Pod name")
cmd.Flags().MarkDeprecated("pod", "This flag is deprecated and will be removed in future. Use exec POD_NAME instead.")
// TODO support UID // TODO support UID
cmd.Flags().StringVarP(&options.ContainerName, "container", "c", options.ContainerName, "Container name. If omitted, the first container in the pod will be chosen") cmd.Flags().StringVarP(&options.ContainerName, "container", "c", options.ContainerName, "Container name. If omitted, the first container in the pod will be chosen")
cmd.Flags().BoolVarP(&options.Stdin, "stdin", "i", options.Stdin, "Pass stdin to the container") cmd.Flags().BoolVarP(&options.Stdin, "stdin", "i", options.Stdin, "Pass stdin to the container")
...@@ -153,7 +154,6 @@ func (p *ExecOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn []s ...@@ -153,7 +154,6 @@ func (p *ExecOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn []s
return cmdutil.UsageErrorf(cmd, execUsageStr) return cmdutil.UsageErrorf(cmd, execUsageStr)
} }
if len(p.PodName) != 0 { if len(p.PodName) != 0 {
printDeprecationWarning(p.ErrOut, "exec POD_NAME", "-p POD_NAME")
if len(argsIn) < 1 { if len(argsIn) < 1 {
return cmdutil.UsageErrorf(cmd, execUsageStr) return cmdutil.UsageErrorf(cmd, execUsageStr)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment