Update ManagementURL in Config (#262)

If ManagementURL is present in the config file
and cmd (e.g. up or login) specifies a new one,
then update config file with a new ManagementURL
This commit is contained in:
Mikhail Bragin
2022-03-13 15:17:18 +01:00
committed by GitHub
parent b2f4322a31
commit e3b809a1d4
3 changed files with 82 additions and 1 deletions

View File

@@ -86,12 +86,18 @@ func ReadConfig(managementURL string, configPath string) (*Config, error) {
return nil, err
}
if managementURL != "" {
if managementURL != "" && config.ManagementURL.String() != managementURL {
URL, err := parseManagementURL(managementURL)
if err != nil {
return nil, err
}
config.ManagementURL = URL
// since we have new management URL, we need to update config file
err = util.WriteJson(configPath, config)
if err != nil {
return nil, err
}
log.Infof("new Management URL provided, updated to %s (old value %s)", managementURL, config.ManagementURL)
}
return config, err