// SetConfigDefaults - XXX func (c *Checks) SetConfigDefaults() error { // Commands already set. For example - in the test suite if len(c.Config.Commands) > 0 { return nil } configFile, err := plugins.ReadPluginConfig("checks") if err != nil { log.WithFields(log.Fields{ "plugin": "checks", "error": err, }).Error("Can't read config file") return err } var Commands []util.Command var CommandStrings []string if e := json.Unmarshal(configFile, &CommandStrings); e != nil { log.WithFields(log.Fields{"plugin": "checks", "error": e.Error()}).Error("Can't decode JSON file") return e } for _, str := range CommandStrings { var command = util.Command{Command: str} Commands = append(Commands, command) } c.Config.Commands = Commands return nil }
// SetConfigDefaults - XXX func (c *Custom) SetConfigDefaults() error { // Commands already set. For example - in the test suite if len(c.Config.Commands) > 0 { return nil } configFile, err := plugins.ReadPluginConfig("custom") if err != nil { log.WithFields(log.Fields{ "plugin": "custom", "error": err, }).Error("Can't read config file") } var Commands []util.Command if e := json.Unmarshal(configFile, &Commands); e != nil { log.WithFields(log.Fields{"plugin": "custom", "error": e.Error()}).Error("Can't decode JSON file") } c.Config.Commands = Commands return nil }