From da2d541a5ca4d0b24a94e5e3938c9d5252fc8407 Mon Sep 17 00:00:00 2001 From: guoxudong Date: Wed, 26 Feb 2020 15:54:07 +0800 Subject: [PATCH 1/3] add judgment for stop and start cmd --- .idea/.gitignore | 2 ++ cli/commands.go | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .idea/.gitignore diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..e7e9d11d --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/cli/commands.go b/cli/commands.go index f3298549..d1022b16 100644 --- a/cli/commands.go +++ b/cli/commands.go @@ -353,7 +353,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 ` to delete other clusters)", c.String("name")) } return fmt.Errorf("No cluster(s) found") @@ -426,6 +426,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 ` 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 { @@ -464,6 +471,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 ` 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 { @@ -526,7 +540,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 ` to check other clusters)", c.String("name")) } return fmt.Errorf("No cluster(s) found") From b5956386445a76c20f696a3c4981f70b906e3006 Mon Sep 17 00:00:00 2001 From: guoxudong Date: Thu, 19 Mar 2020 16:00:20 +0800 Subject: [PATCH 2/3] rm .idea --- .idea/.gitignore | 2 - .idea/k3d.iml | 8 +++ .idea/misc.xml | 6 ++ .idea/modules.xml | 8 +++ .idea/vcs.xml | 6 ++ .idea/workspace.xml | 153 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 181 insertions(+), 2 deletions(-) delete mode 100644 .idea/.gitignore create mode 100644 .idea/k3d.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index e7e9d11d..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml diff --git a/.idea/k3d.iml b/.idea/k3d.iml new file mode 100644 index 00000000..c956989b --- /dev/null +++ b/.idea/k3d.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 00000000..28a804d8 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 00000000..511a3480 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 00000000..91db9ee7 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + /usr/local/bin/dep + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + true + direct + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From f08bb6dad8e1918543d992bc33b066dbb9850414 Mon Sep 17 00:00:00 2001 From: guoxudong Date: Thu, 19 Mar 2020 17:41:21 +0800 Subject: [PATCH 3/3] rm .idea too --- .idea/k3d.iml | 8 --- .idea/misc.xml | 6 -- .idea/modules.xml | 8 --- .idea/vcs.xml | 6 -- .idea/workspace.xml | 153 -------------------------------------------- 5 files changed, 181 deletions(-) delete mode 100644 .idea/k3d.iml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/workspace.xml diff --git a/.idea/k3d.iml b/.idea/k3d.iml deleted file mode 100644 index c956989b..00000000 --- a/.idea/k3d.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 28a804d8..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 511a3480..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index 91db9ee7..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - /usr/local/bin/dep - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - true - direct - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file