From d29560d89aca9727b3d5f7353d3c1b16c4918ffd Mon Sep 17 00:00:00 2001 From: Alexander Campbell Date: Thu, 25 May 2017 12:16:55 -0700 Subject: [PATCH] kubectl: rename Run() -> RunRun() to clarify purpose Run() is too overloaded in the codebase already. The other commands have a pattern of RunExpose, RunScale, and so on. Since the command name is "run", the associated function should be called RunRun. --- pkg/kubectl/cmd/run.go | 4 ++-- pkg/kubectl/cmd/run_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/kubectl/cmd/run.go b/pkg/kubectl/cmd/run.go index be13117ea25..1fb6588fbad 100644 --- a/pkg/kubectl/cmd/run.go +++ b/pkg/kubectl/cmd/run.go @@ -95,7 +95,7 @@ func NewCmdRun(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *co Example: runExample, Run: func(cmd *cobra.Command, args []string) { argsLenAtDash := cmd.ArgsLenAtDash() - err := Run(f, cmdIn, cmdOut, cmdErr, cmd, args, argsLenAtDash) + err := RunRun(f, cmdIn, cmdOut, cmdErr, cmd, args, argsLenAtDash) cmdutil.CheckErr(err) }, } @@ -136,7 +136,7 @@ func addRunFlags(cmd *cobra.Command) { cmd.Flags().String("schedule", "", i18n.T("A schedule in the Cron format the job should be run with.")) } -func Run(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cobra.Command, args []string, argsLenAtDash int) error { +func RunRun(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer, cmd *cobra.Command, args []string, argsLenAtDash int) error { // Let kubectl run follow rules for `--`, see #13004 issue if len(args) == 0 || argsLenAtDash == 0 { return cmdutil.UsageError(cmd, "NAME is required for run") diff --git a/pkg/kubectl/cmd/run_test.go b/pkg/kubectl/cmd/run_test.go index 97c3328f49b..ed3b7860a9e 100644 --- a/pkg/kubectl/cmd/run_test.go +++ b/pkg/kubectl/cmd/run_test.go @@ -181,7 +181,7 @@ func TestRunArgsFollowDashRules(t *testing.T) { cmd := NewCmdRun(f, os.Stdin, os.Stdout, os.Stderr) cmd.Flags().Set("image", "nginx") cmd.Flags().Set("generator", "run/v1") - err := Run(f, os.Stdin, os.Stdout, os.Stderr, cmd, test.args, test.argsLenAtDash) + err := RunRun(f, os.Stdin, os.Stdout, os.Stderr, cmd, test.args, test.argsLenAtDash) if test.expectError && err == nil { t.Errorf("unexpected non-error (%s)", test.name) } @@ -438,7 +438,7 @@ func TestRunValidations(t *testing.T) { for flagName, flagValue := range test.flags { cmd.Flags().Set(flagName, flagValue) } - err := Run(f, inBuf, outBuf, errBuf, cmd, test.args, cmd.ArgsLenAtDash()) + err := RunRun(f, inBuf, outBuf, errBuf, cmd, test.args, cmd.ArgsLenAtDash()) if err != nil && len(test.expectedErr) > 0 { if !strings.Contains(err.Error(), test.expectedErr) { t.Errorf("unexpected error: %v", err)