Merge pull request #108820 from mozillazg/remove-kubectl-deprecated-flags

kubectl: Remove deprecated run flags
This commit is contained in:
Kubernetes Prow Robot 2022-03-24 00:14:50 -07:00 committed by GitHub
commit e3982ce472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -177,11 +177,7 @@ func addRunFlags(cmd *cobra.Command, opt *RunOptions) {
cmd.Flags().String("image-pull-policy", "", i18n.T("The image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server."))
cmd.Flags().Bool("rm", false, "If true, delete the pod after it exits. Only valid when attaching to the container, e.g. with '--attach' or with '-i/--stdin'.")
cmd.Flags().StringArray("env", []string{}, "Environment variables to set in the container.")
cmd.Flags().String("serviceaccount", "", "Service account to set in the pod spec.")
cmd.Flags().MarkDeprecated("serviceaccount", "has no effect and will be removed in 1.24.")
cmd.Flags().StringVar(&opt.Port, "port", opt.Port, i18n.T("The port that this container exposes."))
cmd.Flags().Int("hostport", -1, "The host port mapping for the container port. To demonstrate a single-machine container.")
cmd.Flags().MarkDeprecated("hostport", "has no effect and will be removed in 1.24.")
cmd.Flags().StringP("labels", "l", "", "Comma separated labels to apply to the pod. Will override previous values.")
cmd.Flags().BoolVarP(&opt.Interactive, "stdin", "i", opt.Interactive, "Keep stdin open on the container in the pod, even if nothing is attached.")
cmd.Flags().BoolVarP(&opt.TTY, "tty", "t", opt.TTY, "Allocate a TTY for the container in the pod.")
@ -189,10 +185,6 @@ func addRunFlags(cmd *cobra.Command, opt *RunOptions) {
cmd.Flags().BoolVar(&opt.LeaveStdinOpen, "leave-stdin-open", opt.LeaveStdinOpen, "If the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. By default, stdin will be closed after the first attach completes.")
cmd.Flags().String("restart", "Always", i18n.T("The restart policy for this Pod. Legal values [Always, OnFailure, Never]."))
cmd.Flags().Bool("command", false, "If true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the default.")
cmd.Flags().String("requests", "", i18n.T("The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges."))
cmd.Flags().MarkDeprecated("requests", "has no effect and will be removed in 1.24.")
cmd.Flags().String("limits", "", i18n.T("The resource requirement limits for this container. For example, 'cpu=200m,memory=512Mi'. Note that server side components may assign limits depending on the server configuration, such as limit ranges."))
cmd.Flags().MarkDeprecated("limits", "has no effect and will be removed in 1.24.")
cmd.Flags().BoolVar(&opt.Expose, "expose", opt.Expose, "If true, create a ClusterIP service associated with the pod. Requires `--port`.")
cmd.Flags().BoolVarP(&opt.Quiet, "quiet", "q", opt.Quiet, "If true, suppress prompt messages.")
cmd.Flags().BoolVar(&opt.Privileged, "privileged", opt.Privileged, i18n.T("If true, run the container in privileged mode."))
@ -314,13 +306,6 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e
params["annotations"] = cmdutil.GetFlagStringArray(cmd, "annotations")
params["env"] = cmdutil.GetFlagStringArray(cmd, "env")
// TODO(eddiezane): These flags will be removed for 1.24
// https://github.com/kubernetes/kubectl/issues/1101#issuecomment-916149516
delete(params, "serviceaccount")
delete(params, "hostport")
delete(params, "requests")
delete(params, "limits")
var createdObjects = []*RunObject{}
runObject, err := o.createGeneratedObject(f, cmd, generator, names, params, o.NewOverrider(&corev1.Pod{}))
if err != nil {