Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #628, stop searching for default config location in kapacitord co… #637

Merged
merged 1 commit into from
Jun 10, 2016
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
25 changes: 0 additions & 25 deletions cmd/kapacitord/run/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
}
3 changes: 1 addition & 2 deletions cmd/kapacitord/run/config_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down