Merge pull request #197 from sunny0826/master
[Enhancement] judgment/error-message when specifying non-existent cluster name in start/stop/delete (thanks @sunny0826)
This commit is contained in:
commit
bb7b6e3605
@ -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")
|
||||
@ -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 {
|
||||
@ -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 {
|
||||
@ -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")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user