From b3895b0e0eaeda57c0e8379a87f190ec0163d76f Mon Sep 17 00:00:00 2001 From: ZP-AlwaysWin Date: Sun, 15 Sep 2019 14:27:33 +0800 Subject: [PATCH] fix kubectl run --generator=xxx bug Kubernetes-commit: 860845b58216fa7fa058bacd06b4be5caefa6251 --- pkg/cmd/run/run.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/run/run.go b/pkg/cmd/run/run.go index f292bd39..0be2f79e 100644 --- a/pkg/cmd/run/run.go +++ b/pkg/cmd/run/run.go @@ -339,6 +339,12 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e } } + generators := generateversioned.GeneratorFn("run") + generator, found := generators[generatorName] + if !found { + return cmdutil.UsageErrorf(cmd, "generator %q not found", generatorName) + } + // start deprecating all generators except for 'run-pod/v1' which will be // the only supported on a route to simple kubectl run which should mimic // docker run @@ -346,11 +352,6 @@ func (o *RunOptions) Run(f cmdutil.Factory, cmd *cobra.Command, args []string) e fmt.Fprintf(o.ErrOut, "kubectl run --generator=%s is DEPRECATED and will be removed in a future version. Use kubectl run --generator=%s or kubectl create instead.\n", generatorName, generateversioned.RunPodV1GeneratorName) } - generators := generateversioned.GeneratorFn("run") - generator, found := generators[generatorName] - if !found { - return cmdutil.UsageErrorf(cmd, "generator %q not found", generatorName) - } names := generator.ParamNames() params := generate.MakeParams(cmd, names) params["name"] = args[0]