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:
Thorsten Klein 2020-03-19 14:05:18 +01:00 committed by GitHub
commit bb7b6e3605
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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")