From 18ccf079c228c40456d6ab122001df0bf0431327 Mon Sep 17 00:00:00 2001 From: psbrar99 Date: Thu, 28 Apr 2022 23:46:49 -0600 Subject: [PATCH] fixed test cases --- cmd/istioctl.go | 5 ++++- cmd/istioctl_test.go | 16 ++++++++-------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cmd/istioctl.go b/cmd/istioctl.go index a6daa6b..d61be52 100644 --- a/cmd/istioctl.go +++ b/cmd/istioctl.go @@ -279,8 +279,11 @@ func istioctlProcessChecksArgs(args []string, ourArg *[]string, precheck bool) b hasInstallCMD = true } switch prev { - case "-f", "--filename", "--revision", "-r": + case "--revision", "-r": + *ourArg = append(*ourArg, prev, a) + case "-f", "--filename": *ourArg = append(*ourArg, a) + case "--set", "-s": kv := strings.SplitN(a, "=", 2) if len(kv) != 2 || strings.TrimSpace(kv[0]) != "values.global.istioNamespace" { diff --git a/cmd/istioctl_test.go b/cmd/istioctl_test.go index 469add8..0b96f93 100644 --- a/cmd/istioctl_test.go +++ b/cmd/istioctl_test.go @@ -110,7 +110,7 @@ func TestIstioctl_istioctlParsePreCheckArgs(t *testing.T) { { name: "istioOperator files", args: []string{"install", "-f", "a", "--filename", "b"}, - exp: []string{"x", "precheck", "--kubeconfig", util.GetKubeConfigLocation(), "-f", "a", "--filename", "b"}, + exp: []string{"x", "precheck", "--kubeconfig", util.GetKubeConfigLocation(), "a", "b"}, }, { name: "revision", @@ -125,7 +125,7 @@ func TestIstioctl_istioctlParsePreCheckArgs(t *testing.T) { { name: "istioOperator files", args: []string{"install", "-f", "a", "--filename", "b"}, - exp: []string{"x", "precheck", "--kubeconfig", util.GetKubeConfigLocation(), "-f", "a", "--filename", "b"}, + exp: []string{"x", "precheck", "--kubeconfig", util.GetKubeConfigLocation(), "a", "b"}, }, { name: "help", @@ -147,14 +147,14 @@ func TestIstioctl_istioctlParsePreCheckArgs(t *testing.T) { args: []string{"install", "-s=values.global.istioNamespace=default", "--revision", "canary", "-f", "a", "--filename=b"}, exp: []string{"x", "precheck", "--kubeconfig", util.GetKubeConfigLocation(), - "--istioNamespace", "default", "--revision", "canary", "-f", "a", "--filename", "b"}, + "--istioNamespace", "default", "--revision", "canary", "a", "b"}, }, { name: "full 2", args: []string{"-s=values.global.istioNamespace=default", "--revision", "canary", "-f", "a", "--filename=b", "install"}, exp: []string{"x", "precheck", "--kubeconfig", util.GetKubeConfigLocation(), - "--istioNamespace", "default", "--revision", "canary", "-f", "a", "--filename", "b"}, + "--istioNamespace", "default", "--revision", "canary", "a", "b"}, }, } for _, c := range cases { @@ -184,7 +184,7 @@ func TestIstioctl_istioctlParseVerifyInstallArgs(t *testing.T) { { name: "istioOperator files", args: []string{"install", "-f", "a", "--filename", "b"}, - exp: []string{"verify-install", "--kubeconfig", util.GetKubeConfigLocation(), "-f", "a", "--filename", "b"}, + exp: []string{"verify-install", "--kubeconfig", util.GetKubeConfigLocation(), "a", "b"}, }, { name: "revision", @@ -215,21 +215,21 @@ func TestIstioctl_istioctlParseVerifyInstallArgs(t *testing.T) { name: "eq", args: []string{"install", "--manifests=manifests/", "--set=values.global.istioNamespace=default", "-f=a", "--filename=b"}, exp: []string{"verify-install", "--kubeconfig", util.GetKubeConfigLocation(), "--manifests", "manifests/", - "--istioNamespace", "default", "-f", "a", "--filename", "b"}, + "--istioNamespace", "default", "a", "b"}, }, { name: "full", args: []string{"install", "--set", "values.global.istioNamespace=default", "--revision", "canary", "-f", "a", "--filename", "b", "--manifests", "test/"}, exp: []string{"verify-install", "--kubeconfig", util.GetKubeConfigLocation(), - "--istioNamespace", "default", "--revision", "canary", "-f", "a", "--filename", "b", "--manifests", "test/"}, + "--istioNamespace", "default", "--revision", "canary", "a", "b", "--manifests", "test/"}, }, { name: "full 2", args: []string{"--set", "values.global.istioNamespace=default", "--revision", "canary", "-f", "a", "--filename", "b", "--manifests", "test/", "install"}, exp: []string{"verify-install", "--kubeconfig", util.GetKubeConfigLocation(), - "--istioNamespace", "default", "--revision", "canary", "-f", "a", "--filename", "b", "--manifests", "test/"}, + "--istioNamespace", "default", "--revision", "canary", "a", "b", "--manifests", "test/"}, }, } for _, c := range cases {