mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-26 04:06:38 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user