Apply env overrideds for config command

Matches the behavior of the run command and lets you test env
vars override config values more easily.
pull/3743/head
Jason Wilder 2015-08-19 13:52:28 -06:00
parent b9270cb834
commit 67c54ddc47
1 changed files with 10 additions and 0 deletions

View File

@ -42,11 +42,21 @@ func (cmd *PrintConfigCommand) Run(args ...string) error {
return fmt.Errorf("parse config: %s", err)
}
// Apply any environment variables on top of the parsed config
if err := config.ApplyEnvOverrides(); err != nil {
return fmt.Errorf("apply env config: %v", err)
}
// Override config properties.
if *hostname != "" {
config.Meta.Hostname = *hostname
}
// Validate the configuration.
if err := config.Validate(); err != nil {
return fmt.Errorf("%s. To generate a valid configuration file run `influxd config > influxdb.generated.conf`.", err)
}
toml.NewEncoder(cmd.Stdout).Encode(config)
fmt.Fprint(cmd.Stdout, "\n")