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
```
pull/8/head
Kubernetes Submit Queue 2018-07-27 18:05:06 -07:00 committed by GitHub
commit ce227b06de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -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().MarkDeprecated("pod", "This flag is deprecated and will be removed in future. Use exec POD_NAME instead.")
// 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().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
return cmdutil.UsageErrorf(cmd, execUsageStr)
}
if len(p.PodName) != 0 {
printDeprecationWarning(p.ErrOut, "exec POD_NAME", "-p POD_NAME")
if len(argsIn) < 1 {
return cmdutil.UsageErrorf(cmd, execUsageStr)
}