Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions collector/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ func (c *configuration) Init() error {
c.SetDefault("commands.metrics_info_args", "--info --json")
c.SetDefault("commands.metrics_smart_args", "--xall --json")
c.SetDefault("commands.metrics_smartctl_wait", 0)

c.SetDefault("commands.allow_custom", "no")

//configure env variable parsing.
c.SetEnvPrefix("COLLECTOR")
c.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
c.AutomaticEnv()

//c.SetDefault("collect.short.command", "-a -o on -S on")

c.SetDefault("allow_listed_devices", []string{})
Expand Down Expand Up @@ -103,11 +103,13 @@ func (c *configuration) ReadConfig(configFilePath string) error {

// This function ensures that the merged config works correctly.
func (c *configuration) ValidateConfig() error {

//TODO:
// check that device prefix matches OS
// check that schema of config file is valid

if(c.GetString("commands.allow_custom")=="yes"){
return nil
}
// check that the collector commands are valid
commandArgStrings := map[string]string{
"commands.metrics_scan_args": c.GetString("commands.metrics_scan_args"),
Expand Down