Explorar el Código

reset CLI config when host is changed

Mohammed Nafees hace 3 años
padre
commit
9a4cc207c4
Se han modificado 1 ficheros con 11 adiciones y 1 borrados
  1. 11 1
      cli/cmd/config/config.go

+ 11 - 1
cli/cmd/config/config.go

@@ -199,14 +199,24 @@ func (c *CLIConfig) SetHost(host string) error {
 	host = strings.TrimRight(host, "/")
 
 	viper.Set("host", host)
-	color.New(color.FgGreen).Printf("Set the current host as %s\n", host)
+
+	// let us clear the project ID, cluster ID, and token when we reset a host
+	viper.Set("project", 0)
+	viper.Set("cluster", 0)
+	viper.Set("token", "")
+
 	err := viper.WriteConfig()
 
 	if err != nil {
 		return err
 	}
 
+	color.New(color.FgGreen).Printf("Set the current host as %s\n", host)
+
 	config.Host = host
+	config.Project = 0
+	config.Cluster = 0
+	config.Token = ""
 
 	return nil
 }