From 594cdc6ed182aebdd56612c11d08829a6a15bdb4 Mon Sep 17 00:00:00 2001 From: Peter Rifel Date: Mon, 8 Mar 2021 11:35:36 -0600 Subject: [PATCH] kubetest2 - don't overwrite create args that use equals signs Previously we would incorrectly append create cluster arguments if they had already been specified and used --foo=bar notation. This resulted in arguments being specified multiple times causing undesired behavior. We now check for both `--foo bar` and `--foo=bar` when attempting to add a `--foo` argument. --- tests/e2e/kubetest2-kops/deployer/up.go | 3 ++- tests/e2e/kubetest2-kops/deployer/up_test.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/e2e/kubetest2-kops/deployer/up.go b/tests/e2e/kubetest2-kops/deployer/up.go index 34bb73ecfcb79..f687315fee260 100644 --- a/tests/e2e/kubetest2-kops/deployer/up.go +++ b/tests/e2e/kubetest2-kops/deployer/up.go @@ -193,7 +193,8 @@ func (d *deployer) zones() ([]string, error) { // This shouldn't be used for arguments that can be specified multiple times like --override func appendIfUnset(args []string, arg, value string) []string { for _, existingArg := range args { - if existingArg == arg { + existingKey := strings.Split(existingArg, "=") + if existingKey[0] == arg { return args } } diff --git a/tests/e2e/kubetest2-kops/deployer/up_test.go b/tests/e2e/kubetest2-kops/deployer/up_test.go index 3e5677ffec868..9090590c53043 100644 --- a/tests/e2e/kubetest2-kops/deployer/up_test.go +++ b/tests/e2e/kubetest2-kops/deployer/up_test.go @@ -64,6 +64,13 @@ func TestAppendIfUnset(t *testing.T) { "bar", []string{"--foo", "bar"}, }, + { + "set with same value and equals sign", + []string{"--foo=bar", "--baz=bar"}, + "--foo", + "bar", + []string{"--foo=bar", "--baz=bar"}, + }, } for _, tc := range cases {