Skip to content

Commit

Permalink
remove deprecated-sensu feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Mar 4, 2016
1 parent 7c79f92 commit 5d775e8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
20 changes: 1 addition & 19 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ type Config struct {
// the key of the map is <kind>, which should be one of "metrics" or "checks".
Plugin map[string]PluginConfigs

DeprecatedSensu map[string]PluginConfigs `toml:"sensu"` // DEPRECATED this is for backward compatibility
Include string
Include string

// Cannot exist in configuration files
HostIDStorage HostIDStorage
Expand Down Expand Up @@ -173,23 +172,6 @@ func loadConfigFile(file string) (*Config, error) {
return config, err
}
}

// for backward compatibility
// merges sensu configs to plugin configs
if _, ok := config.DeprecatedSensu["checks"]; ok {
configLogger.Warningf("'sensu.checks.*' config format is DEPRECATED. Please use 'plugin.metrics.*' format.")

if config.Plugin == nil {
config.Plugin = map[string]PluginConfigs{}
}
if _, ok := config.Plugin["metrics"]; !ok {
config.Plugin["metrics"] = PluginConfigs{}
}
for k, v := range config.DeprecatedSensu["checks"] {
config.Plugin["metrics"]["DEPRECATED-sensu-"+k] = v
}
}

return config, nil
}

Expand Down
10 changes: 0 additions & 10 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ post_metrics_retry_max = 5
[plugin.metrics.mysql]
command = "ruby /path/to/your/plugin/mysql.rb"
[sensu.checks.memory] # for backward compatibility
command = "ruby ../sensu/plugins/system/memory-metrics.rb"
type = "metric"
[plugin.checks.heartbeat]
command = "heartbeat.sh"
notification_interval = 60
Expand Down Expand Up @@ -181,12 +177,6 @@ func TestLoadConfigFile(t *testing.T) {
t.Errorf("plugin conf command should be 'ruby /path/to/your/plugin/mysql.rb' but %v", pluginConf.Command)
}

// for backward compatibility
sensu := config.Plugin["metrics"]["DEPRECATED-sensu-memory"]
if sensu.Command != "ruby ../sensu/plugins/system/memory-metrics.rb" {
t.Error("sensu command should be 'ruby ../sensu/plugins/system/memory-metrics.rb'")
}

if config.Plugin["checks"] == nil {
t.Error("plugin should have checks")
}
Expand Down

0 comments on commit 5d775e8

Please sign in to comment.