Change:
When running , if you don't specify the deprecated and instead just do , it doesn't strip off the 1st command line arg, so sends the command to the container, whereas correctly sends just Regression from
FYI
We still support --, correct?
yes, we still support , but it's marked deprecated.
cc
has the fix. (and better unit test coverage) Sorry for the breakage!

Discussion:
tty           bool } <del> func extractPodAndContainer(cmd *cobra.Command, args []string, p *execParams) (podName string, containerName string, err error) { if len(p.podName) == 0 && len(args) == 0 { return "", "", cmdutil.UsageError(cmd, "POD is required for exec") </del> <ins> func extractPodAndContainer(cmd *cobra.Command, argsIn []string, p *execParams) (podName string, containerName string, args []string, err error) { if len(p.podName) == 0 && len(argsIn) == 0 { return "", "", nil, cmdutil.UsageError(cmd, "POD is required for exec") </ins> } if len(p.podName) != 0 { printDeprecationWarning("exec POD", "-p POD") podName = p.podName <del> if len(args) < 1 { return "", "", cmdutil.UsageError(cmd, "COMMAND is required for exec") </del> <ins> if len(argsIn) < 1 { return "", "", nil, cmdutil.UsageError(cmd, "COMMAND is required for exec") </ins> } <ins> args = argsIn </ins> } else { <del> podName = args[0] if len(args) < 2 { return "", "", cmdutil.UsageError(cmd, "COMMAND is required for exec") </del> <ins> podName = argsIn[0] args = argsIn[1:] if len(args) < 1 { return "", "", nil, cmdutil.UsageError(cmd, "COMMAND is required for exec") </ins> } } <del> return podName, p.containerName, nil </del> <ins> return podName, p.containerName, args, nil </ins> } <del> func RunExec(f *cmdutil.Factory, cmd *cobra.Command, cmdIn io.Reader, cmdOut, cmdErr io.Writer, p *execParams, args []string, re remoteExecutor) error { podName, containerName, err := extractPodAndContainer(cmd, args, p) </del> <ins> func RunExec(f *cmdutil.Factory, cmd *cobra.Command, cmdIn io.Reader, cmdOut, cmdErr io.Writer, p *execParams, argsIn []string, re remoteExecutor) error { podName, containerName, args, err := extractPodAndContainer(cmd, argsIn, p) </ins> namespace, err := f.DefaultNamespace() if err != nil { return err

"fmt" "io" "net/http" <ins> "reflect" </ins> "testing" "github.com/spf13/cobra"

tests := []struct { args              []string p                 *execParams <ins> name              string </ins> expectError       bool expectedPod       string expectedContainer string <ins> expectedArgs      []string </ins> }{ { p:           &execParams{}, expectError: true, <ins> name:        "empty", </ins> }, { p:           &execParams{podName: "foo"}, expectError: true, <ins> name:        "no cmd", </ins> }, { p:           &execParams{podName: "foo", containerName: "bar"}, expectError: true, <ins> name:        "no cmd, w/ container", </ins> }, { <del> p:           &execParams{podName: "foo"}, args:        []string{"cmd"}, expectedPod: "foo", </del> <ins> p:            &execParams{podName: "foo"}, args:         []string{"cmd"}, expectedPod:  "foo", expectedArgs: []string{"cmd"}, name:         "pod in flags", </ins> }, { p:           &execParams{}, args:        []string{"foo"}, expectError: true, <ins> name:        "no cmd, w/o flags", </ins> }, { <del> p:           &execParams{}, args:        []string{"foo", "cmd"}, expectedPod: "foo", </del> <ins> p:            &execParams{}, args:         []string{"foo", "cmd"}, expectedPod:  "foo", expectedArgs: []string{"cmd"}, name:         "cmd, w/o flags", </ins> }, { p:                 &execParams{containerName: "bar"}, args:              []string{"foo", "cmd"}, expectedPod:       "foo", expectedContainer: "bar", <ins> expectedArgs:      []string{"cmd"}, name:              "cmd, container in flag", </ins> }, } for _, test := range tests { cmd := &cobra.Command{} <del> podName, containerName, err := extractPodAndContainer(cmd, test.args, test.p) </del> <ins> podName, containerName, args, err := extractPodAndContainer(cmd, test.args, test.p) </ins> if podName != test.expectedPod { <del> t.Errorf("expected: %s, got: %s", test.expectedPod, podName) </del> <ins> t.Errorf("expected: %s, got: %s (%s)", test.expectedPod, podName, test.name) </ins> } if containerName != test.expectedContainer { <del> t.Errorf("expected: %s, got: %s", test.expectedContainer, containerName) </del> <ins> t.Errorf("expected: %s, got: %s (%s)", test.expectedContainer, containerName, test.name) </ins> } if test.expectError && err == nil { <del> t.Error("unexpected non-error") </del> <ins> t.Errorf("unexpected non-error (%s)", test.name) </ins> } if !test.expectError && err != nil { <del> t.Errorf("unexpected error: %v", err) </del> <ins> t.Errorf("unexpected error: %v (%s)", err, test.name) } if !reflect.DeepEqual(test.expectedArgs, args) { t.Errorf("expected: %v, got %v (%s)", test.expectedArgs, args, test.name) </ins> } } }