Skip to content

Commit

Permalink
Avoid overwritting of dp config
Browse files Browse the repository at this point in the history
If DataPower configuration flag is passed on command line don't
overwrite existing configuration with same name.
  • Loading branch information
vvidovic committed Dec 23, 2019
1 parent 276cebd commit f717aba
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ func initConfiguration() {
logging.LogDebug("config/initConfiguration() - Conf after read: ", Conf)
if *dpRestURL != "" || *dpSomaURL != "" {
if *dpConfigName != "" {
validateDpConfigName()
Conf.DataPowerAppliances[*dpConfigName] = DataPowerAppliance{Domain: *dpDomain, Proxy: *proxy, RestUrl: *dpRestURL, SomaUrl: *dpSomaURL, Username: *dpUsername, Password: *dpPassword}
CurrentApplianceName = *dpConfigName
} else {
Expand Down Expand Up @@ -214,6 +215,16 @@ func validateProgramArgs() {
(*dpUsername != "" && *dpRestURL == "" && *dpSomaURL == "") {
usage(1)
}

}

// validateDpConfigName validate DataPower appliance configuration name passed
// as command line param to avoid overwritting of existing configuration.
func validateDpConfigName() {
if _, ok := Conf.DataPowerAppliances[*dpConfigName]; ok {
fmt.Printf("DataPower appliance configuration with name '%s' already exists.\n\n", *dpConfigName)
usage(2)
}
}

// validatePassword validates password argument and asks for password input
Expand Down

0 comments on commit f717aba

Please sign in to comment.