Procházet zdrojové kódy

reset CLI config when host is changed

Mohammed Nafees před 3 roky
rodič
revize
9a4cc207c4
1 změnil soubory, kde provedl 11 přidání a 1 odebrání
  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, "/")
 	host = strings.TrimRight(host, "/")
 
 
 	viper.Set("host", 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()
 	err := viper.WriteConfig()
 
 
 	if err != nil {
 	if err != nil {
 		return err
 		return err
 	}
 	}
 
 
+	color.New(color.FgGreen).Printf("Set the current host as %s\n", host)
+
 	config.Host = host
 	config.Host = host
+	config.Project = 0
+	config.Cluster = 0
+	config.Token = ""
 
 
 	return nil
 	return nil
 }
 }