Skip to content

Commit

Permalink
Merge pull request #197 from sunny0826/master
Browse files Browse the repository at this point in the history
[Enhancement] judgment/error-message when specifying non-existent cluster name in start/stop/delete (thanks @sunny0826)
  • Loading branch information
iwilltry42 authored Mar 19, 2020
2 parents 9048c75 + f08bb6d commit bb7b6e3
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func DeleteCluster(c *cli.Context) error {
}

if len(clusters) == 0 {
if !c.IsSet("all") && !c.IsSet("name") {
if !c.IsSet("all") && c.IsSet("name") {
return fmt.Errorf("No cluster with name '%s' found (You can add `--all` and `--name <CLUSTER-NAME>` to delete other clusters)", c.String("name"))
}
return fmt.Errorf("No cluster(s) found")
Expand Down Expand Up @@ -428,6 +428,13 @@ func StopCluster(c *cli.Context) error {
return err
}

if len(clusters) == 0 {
if !c.IsSet("all") && c.IsSet("name") {
return fmt.Errorf("No cluster with name '%s' found (You can add `--all` and `--name <CLUSTER-NAME>` to stop other clusters)", c.String("name"))
}
return fmt.Errorf("No cluster(s) found")
}

ctx := context.Background()
docker, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
Expand Down Expand Up @@ -466,6 +473,13 @@ func StartCluster(c *cli.Context) error {
return err
}

if len(clusters) == 0 {
if !c.IsSet("all") && c.IsSet("name") {
return fmt.Errorf("No cluster with name '%s' found (You can add `--all` and `--name <CLUSTER-NAME>` to start other clusters)", c.String("name"))
}
return fmt.Errorf("No cluster(s) found")
}

ctx := context.Background()
docker, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
Expand Down Expand Up @@ -528,7 +542,7 @@ func GetKubeConfig(c *cli.Context) error {
}

if len(clusters) == 0 {
if !c.IsSet("all") && !c.IsSet("name") {
if !c.IsSet("all") && c.IsSet("name") {
return fmt.Errorf("No cluster with name '%s' found (You can add `--all` and `--name <CLUSTER-NAME>` to check other clusters)", c.String("name"))
}
return fmt.Errorf("No cluster(s) found")
Expand Down

0 comments on commit bb7b6e3

Please sign in to comment.