Skip to content

Commit

Permalink
Feature: Use automatic binding of env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
datenzar committed Oct 14, 2024
1 parent 604dcf3 commit a783604
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions collector/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,10 @@ func (c *configuration) Init() error {
c.SetDefault("commands.metrics_info_args", "--info --json")
c.SetDefault("commands.metrics_smart_args", "--xall --json")

// Bind environment variables with COLLECTOR_ prefix
c.BindEnv("host.id", "COLLECTOR_HOST_ID")
c.BindEnv("log.level", "COLLECTOR_LOG_LEVEL")
c.BindEnv("log.file", "COLLECTOR_LOG_FILE")
c.BindEnv("api.endpoint", "COLLECTOR_API_ENDPOINT")
c.BindEnv("commands.metrics_smartctl_bin", "COLLECTOR_COMMANDS_METRICS_SMARTCTL_BIN")
c.BindEnv("commands.metrics_scan_args", "COLLECTOR_COMMANDS_METRICS_SCAN_ARGS")
c.BindEnv("commands.metrics_info_args", "COLLECTOR_COMMANDS_METRICS_INFO_ARGS")
c.BindEnv("commands.metrics_smart_args", "COLLECTOR_COMMANDS_METRICS_SMART_ARGS")
//configure env variable parsing.
c.SetEnvPrefix("COLLECTOR")
c.SetEnvKeyReplacer(strings.NewReplacer("-", "_", ".", "_"))
c.AutomaticEnv()

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

Expand Down

0 comments on commit a783604

Please sign in to comment.