From 2e761cd18989d7e075f0527dede5563c4ce48db8 Mon Sep 17 00:00:00 2001 From: Steffen Siering Date: Tue, 19 Jul 2016 15:05:51 +0200 Subject: [PATCH] fix printing default config file path (#2060) --- libbeat/cfgfile/cfgfile.go | 2 +- libbeat/cfgfile/flags.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libbeat/cfgfile/cfgfile.go b/libbeat/cfgfile/cfgfile.go index 3ccaf684d38..5320622ec28 100644 --- a/libbeat/cfgfile/cfgfile.go +++ b/libbeat/cfgfile/cfgfile.go @@ -14,7 +14,7 @@ var ( // The default config cannot include the beat name as it is not initialized // when this variable is created. See ChangeDefaultCfgfileFlag which should // be called prior to flags.Parse(). - configfiles = flagArgList("c", "beat.yml", "Configuration file") + configfiles = flagArgList("c", "beat.yml", "Configuration file `path`") overwrites = common.NewFlagConfig(nil, nil, "E", "Configuration overwrite") testConfig = flag.Bool("configtest", false, "Test configuration and exit.") diff --git a/libbeat/cfgfile/flags.go b/libbeat/cfgfile/flags.go index 8976dbf21c0..9daa2e65701 100644 --- a/libbeat/cfgfile/flags.go +++ b/libbeat/cfgfile/flags.go @@ -8,6 +8,7 @@ import ( type argList struct { list []string isDefault bool + f *flag.Flag } func flagArgList(name string, def string, usage string) *argList { @@ -16,10 +17,15 @@ func flagArgList(name string, def string, usage string) *argList { isDefault: true, } flag.Var(l, name, usage) + l.f = flag.Lookup(name) + if l.f == nil { + panic("Failed to lookup registered flag") + } return l } func (l *argList) SetDefault(v string) { + l.f.DefValue = v l.list = []string{v} l.isDefault = true }