diff --git a/control/config.go b/control/config.go index 2b02d0f40..79b414255 100644 --- a/control/config.go +++ b/control/config.go @@ -152,71 +152,6 @@ func GetDefaultConfig() *Config { } } -// UnmarshalJSON unmarshals valid json into a Config. An example Config can be found -// at github.com/intelsdi-x/snap/blob/master/examples/configs/snap-config-sample.json -func (c *Config) UnmarshalJSON(data []byte) error { - // construct a map of strings to json.RawMessages (to defer the parsing of individual - // fields from the unmarshalled interface until later) and unmarshal the input - // byte array into that map - t := make(map[string]json.RawMessage) - if err := json.Unmarshal(data, &t); err != nil { - return err - } - // loop through the individual map elements, parse each in turn, and set - // the appropriate field in this configuration - for k, v := range t { - switch k { - case "max_running_plugins": - if err := json.Unmarshal(v, &(c.MaxRunningPlugins)); err != nil { - return fmt.Errorf("%v (while parsing 'control::max_running_plugins')", err) - } - case "plugin_load_timeout": - if err := json.Unmarshal(v, &(c.PluginLoadTimeout)); err != nil { - return fmt.Errorf("%v (while parsing 'control::plugin_load_timeout')", err) - } - case "plugin_trust_level": - if err := json.Unmarshal(v, &(c.PluginTrust)); err != nil { - return fmt.Errorf("%v (while parsing 'control::plugin_trust_level')", err) - } - case "auto_discover_path": - if err := json.Unmarshal(v, &(c.AutoDiscoverPath)); err != nil { - return fmt.Errorf("%v (while parsing 'control::auto_discover_path')", err) - } - case "keyring_paths": - if err := json.Unmarshal(v, &(c.KeyringPaths)); err != nil { - return fmt.Errorf("%v (while parsing 'control::keyring_paths')", err) - } - case "cache_expiration": - if err := json.Unmarshal(v, &(c.CacheExpiration)); err != nil { - return fmt.Errorf("%v (while parsing 'control::cache_expiration')", err) - } - case "plugins": - if err := json.Unmarshal(v, c.Plugins); err != nil { - return err - } - case "listen_addr": - if err := json.Unmarshal(v, &(c.ListenAddr)); err != nil { - return err - } - case "listen_port": - if err := json.Unmarshal(v, &(c.ListenPort)); err != nil { - return err - } - case "pprof": - if err := json.Unmarshal(v, &(c.Pprof)); err != nil { - return err - } - case "max_plugin_restarts": - if err := json.Unmarshal(v, &(c.MaxPluginRestarts)); err != nil { - return err - } - default: - return fmt.Errorf("Unrecognized key '%v' in global config file while parsing 'control'", k) - } - } - return nil -} - // NewPluginsConfig returns a map of *pluginConfigItems where the key is the plugin name. func NewPluginsConfig() map[string]*pluginConfigItem { return map[string]*pluginConfigItem{}