Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor][kubectl-plugin] require one posarg in session #3017

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions kubectl-plugin/pkg/cmd/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func NewClusterLogCommand(streams genericclioptions.IOStreams) *cobra.Command {
Example: logExample,
Aliases: []string{"logs"},
SilenceUsage: true,
Args: cobra.ExactArgs(1),
ValidArgsFunction: completion.RayClusterResourceNameCompletionFunc(cmdFactory),
RunE: func(cmd *cobra.Command, args []string) error {
if err := options.Complete(cmd, args); err != nil {
Expand All @@ -106,10 +107,6 @@ func NewClusterLogCommand(streams genericclioptions.IOStreams) *cobra.Command {
}

func (options *ClusterLogOptions) Complete(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return cmdutil.UsageErrorf(cmd, "%s", cmd.Use)
}

if *options.configFlags.Namespace == "" {
*options.configFlags.Namespace = "default"
}
Expand Down
10 changes: 0 additions & 10 deletions kubectl-plugin/pkg/cmd/log/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,6 @@ func TestRayClusterLogComplete(t *testing.T) {
expectedNodeType: "all",
hasErr: false,
},
{
name: "invalid args (no args)",
args: []string{},
hasErr: true,
},
{
name: "invalid args (too many args)",
args: []string{"raycluster/test-raycluster", "extra-arg"},
hasErr: true,
},
{
name: "invalid args (no resource type)",
args: []string{"/test-resource"},
Expand Down
5 changes: 1 addition & 4 deletions kubectl-plugin/pkg/cmd/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func NewSessionCommand(streams genericiooptions.IOStreams) *cobra.Command {
Short: "Forward local ports to the Ray resources.",
Long: sessionLong,
Example: sessionExample,
Args: cobra.ExactArgs(1),
ValidArgsFunction: completion.RayClusterResourceNameCompletionFunc(factory),
RunE: func(cmd *cobra.Command, args []string) error {
if err := options.Complete(cmd, args); err != nil {
Expand All @@ -106,10 +107,6 @@ func NewSessionCommand(streams genericiooptions.IOStreams) *cobra.Command {
}

func (options *SessionOptions) Complete(cmd *cobra.Command, args []string) error {
if len(args) != 1 {
return cmdutil.UsageErrorf(cmd, "%s", cmd.Use)
}

typeAndName := strings.Split(args[0], "/")
if len(typeAndName) == 1 {
options.ResourceType = util.RayCluster
Expand Down
10 changes: 0 additions & 10 deletions kubectl-plugin/pkg/cmd/session/session_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,6 @@ func TestComplete(t *testing.T) {
expectedName: "test-resource",
hasErr: false,
},
{
name: "invalid args (no args)",
args: []string{},
hasErr: true,
},
{
name: "invalid args (too many args)",
args: []string{"raycluster/test-raycluster", "extra-arg"},
hasErr: true,
},
{
name: "invalid args (no resource type)",
args: []string{"/test-resource"},
Expand Down
Loading