Check for cluster existence before using a name to create a new cluster

This change improve the error message. It also avoids the tricky situation of
potentially destroying an existing clusters when the same name cluster
creation fails. For more details see issue #42.
pull/47/head
Andy Zhou 5 years ago
parent b48debb176
commit 3c3c72b4af
  1. 7
      cli/commands.go

@ -52,6 +52,13 @@ func CreateCluster(c *cli.Context) error {
return err
}
if cluster, err := getClusters(false, c.String("name")); err != nil {
return err
} else if len(cluster) != 0 {
// A cluster exists with the same name. Return with an error.
return fmt.Errorf("ERROR: Cluster %s already exists", c.String("name"))
}
// define image
image := c.String("image")
if c.IsSet("version") {

Loading…
Cancel
Save