Skip to content

Commit

Permalink
Override defaults with old config params
Browse files Browse the repository at this point in the history
Giving a deprecation message
  • Loading branch information
Victor Castell committed Sep 17, 2018
1 parent af43f8c commit 3bca25f
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cmd/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,25 +144,25 @@ func handleReload() {
// Suport legacy config files for some time
func legacyConfig() {
s := viper.GetString("node_name")
if s != "" && viper.GetString("node-name") == "" {
if s != "" {
log.WithField("param", "node_name").Warn("Deprecation warning: Config param name is deprecated and will be removed in future versions.")
config.NodeName = s
}

s = viper.GetString("bind_addr")
if s != "" && viper.GetString("bind-addr") == "" {
if s != "" {
log.WithField("param", "bind_addr").Warn("Deprecation warning: Config param name is deprecated and will be removed in future versions.")
config.BindAddr = s
}

s = viper.GetString("http_addr")
if s != "" && viper.GetString("http-addr") == "" {
if s != "" {
log.WithField("param", "http_addr").Warn("Deprecation warning: Config param name is deprecated and will be removed in future versions.")
config.HTTPAddr = s
}

ss := viper.GetStringSlice("backend_machine")
if ss != nil && viper.GetStringSlice("backend_machine") == nil {
if ss != nil {
log.WithField("param", "backend_machine").Warn("Deprecation warning: Config param name is deprecated and will be removed in future versions.")
config.BackendMachines = ss
}
Expand Down Expand Up @@ -228,7 +228,7 @@ func legacyConfig() {
}

i := viper.GetInt("rpc_port")
if i != 0 && viper.GetInt("rpc-port") == 0 {
if i != 0 {
log.WithField("param", "rpc_port").Warn("Deprecation warning: Config param name is deprecated and will be removed in future versions.")
config.RPCPort = i
}
Expand All @@ -240,7 +240,7 @@ func legacyConfig() {
}

s = viper.GetString("log_level")
if s != "" && viper.GetString("log-level") == "" {
if s != "" {
log.WithField("param", "log_level").Warn("Deprecation warning: Config param name is deprecated and will be removed in future versions.")
config.LogLevel = s
}
Expand Down Expand Up @@ -282,7 +282,7 @@ func legacyConfig() {
}

s = viper.GetString("mail_subject_prefix")
if s != "" && viper.GetString("mail-subject-prefix") == "" {
if s != "" {
log.WithField("param", "mail_subject_prefix").Warn("Deprecation warning: Config param name is deprecated and will be removed in future versions.")
config.MailSubjectPrefix = s
}
Expand Down

0 comments on commit 3bca25f

Please sign in to comment.