From 64ae6affc5324f4cb0b6ceeccecb67af32f158f0 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 3 Sep 2020 10:39:46 -0700 Subject: [PATCH 1/2] Missing registering debug/config flags on server subcommand Signed-off-by: Darren Shepherd --- pkg/cli/cmds/root.go | 2 +- pkg/cli/cmds/server.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/cli/cmds/root.go b/pkg/cli/cmds/root.go index 8233fcb90e..423b8dce65 100644 --- a/pkg/cli/cmds/root.go +++ b/pkg/cli/cmds/root.go @@ -13,7 +13,7 @@ var ( Debug bool DebugFlag = cli.BoolFlag{ Name: "debug", - Usage: "Turn on debug logs", + Usage: "(logging) Turn on debug logs", Destination: &Debug, EnvVar: version.ProgramUpper + "_DEBUG", } diff --git a/pkg/cli/cmds/server.go b/pkg/cli/cmds/server.go index 5b4e61ae76..367b8e3d60 100644 --- a/pkg/cli/cmds/server.go +++ b/pkg/cli/cmds/server.go @@ -77,6 +77,8 @@ func NewServerCommand(action func(*cli.Context) error) cli.Command { Before: SetupDebug(CheckSELinuxFlags), Action: action, Flags: []cli.Flag{ + ConfigFlag, + DebugFlag, VLevel, VModule, LogFile, From 289ba8df6a70c97a78b32de4f732a961c6e00296 Mon Sep 17 00:00:00 2001 From: Darren Shepherd Date: Thu, 3 Sep 2020 15:00:12 -0700 Subject: [PATCH 2/2] All arguments should be of the form --k=v so that bool flags will work Previously a bool flag would be rendered as --flag false for `flag: false` which is invalid and results in the opposite of what you'd expect. Signed-off-by: Darren Shepherd --- pkg/configfilearg/parser.go | 8 ++------ pkg/configfilearg/parser_test.go | 17 +++++++++-------- pkg/configfilearg/testdata/data.yaml | 1 + 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pkg/configfilearg/parser.go b/pkg/configfilearg/parser.go index 600e56f413..4533fcac8a 100644 --- a/pkg/configfilearg/parser.go +++ b/pkg/configfilearg/parser.go @@ -104,15 +104,11 @@ func readConfigFile(file string) (result []string, _ error) { if slice, ok := v.([]interface{}); ok { for _, v := range slice { - result = append(result, prefix+k, convert.ToString(v)) - result = append(result) + result = append(result, prefix+k+"="+convert.ToString(v)) } } else { str := convert.ToString(v) - result = append(result, prefix+k) - if str != "" { - result = append(result, str) - } + result = append(result, prefix+k+"="+str) } } diff --git a/pkg/configfilearg/parser_test.go b/pkg/configfilearg/parser_test.go index 47145e1daa..675a53f68a 100644 --- a/pkg/configfilearg/parser_test.go +++ b/pkg/configfilearg/parser_test.go @@ -150,14 +150,15 @@ func TestConfigFile(t *testing.T) { func TestParse(t *testing.T) { testDataOutput := []string{ - "--foo-bar", "baz", - "--a-slice", "1", - "--a-slice", "2", - "--a-slice", "", - "--a-slice", "three", - "--isempty", - "-c", "b", - "--islast", "true", + "--foo-bar=baz", + "--a-slice=1", + "--a-slice=2", + "--a-slice=", + "--a-slice=three", + "--isempty=", + "-c=b", + "--isfalse=false", + "--islast=true", } defParser := Parser{ diff --git a/pkg/configfilearg/testdata/data.yaml b/pkg/configfilearg/testdata/data.yaml index 61910e4d1a..35105341ad 100644 --- a/pkg/configfilearg/testdata/data.yaml +++ b/pkg/configfilearg/testdata/data.yaml @@ -6,4 +6,5 @@ a-slice: - three isempty: c: b +isfalse: false islast: true \ No newline at end of file