From 964ac229eea3afb9fac47f4d2462e9a3aec871e2 Mon Sep 17 00:00:00 2001 From: Nathaniel Cook Date: Fri, 10 Jun 2016 11:31:41 -0600 Subject: [PATCH] fix #628, stop searching for default config location in kapacitord config cmd --- CHANGELOG.md | 5 ++++- cmd/kapacitord/run/command.go | 25 ------------------------- cmd/kapacitord/run/config_command.go | 3 +-- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23c627f50..76c46d78b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,10 @@ - [#621](https://github.com/influxdata/kapacitor/pull/621): Fix obscure error about single vs double quotes. - [#623](https://github.com/influxdata/kapacitor/pull/623): Fix issues with recording metadata missing data url. -- [#631](https://github.com/influxdata/kapacitor/pull/631): Fix issues with using iterative lambda expressions in an EvalNode. +- [#631](https://github.com/influxdata/kapacitor/issue/631): Fix issues with using iterative lambda expressions in an EvalNode. +- [#628](https://github.com/influxdata/kapacitor/issue/628): BREAKING: Change `kapacitord config` to not search default location for configuration files but rather require the `-config` option. + Since the `kapacitord run` command behaves this way they should be consistent. + Fix issue with `kapacitord config > kapacitor.conf` when the output file was a default location for the config. ## v1.0.0-beta1 [2016-06-06] diff --git a/cmd/kapacitord/run/command.go b/cmd/kapacitord/run/command.go index 308411ca1..359c59d29 100644 --- a/cmd/kapacitord/run/command.go +++ b/cmd/kapacitord/run/command.go @@ -251,28 +251,3 @@ type Options struct { LogFile string LogLevel string } - -// GetConfigPath returns the config path from the options. -// It will return a path by searching in this order: -// 1. The CLI option in ConfigPath -// 2. The environment variable KAPACITOR_CONFIG_PATH -// 3. The first influxdb.conf file on the path: -// - ~/.kapacitor -// - /etc/kapacitor -func (opt *Options) GetConfigPath() string { - if opt.ConfigPath != "" { - return opt.ConfigPath - } else if envVar := os.Getenv("KAPACITOR_CONFIG_PATH"); envVar != "" { - return envVar - } - - for _, path := range []string{ - os.ExpandEnv("${HOME}/.kapacitor/kapacitor.conf"), - "/etc/kapacitor/kapacitor.conf", - } { - if _, err := os.Stat(path); err == nil { - return path - } - } - return "" -} diff --git a/cmd/kapacitord/run/config_command.go b/cmd/kapacitord/run/config_command.go index 5227e5e8a..87a41e148 100644 --- a/cmd/kapacitord/run/config_command.go +++ b/cmd/kapacitord/run/config_command.go @@ -37,8 +37,7 @@ func (cmd *PrintConfigCommand) Run(args ...string) error { } // Parse config from path. - opt := Options{ConfigPath: *configPath} - config, err := cmd.parseConfig(opt.GetConfigPath()) + config, err := cmd.parseConfig(*configPath) if err != nil { return fmt.Errorf("parse config: %s", err) }