Skip to content

Commit

Permalink
fix for #93 (#96)
Browse files Browse the repository at this point in the history
* fix for #93

* fixed test cases
  • Loading branch information
psbrar99 authored May 4, 2022
1 parent bdd61ac commit 9aef432
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 4 additions & 1 deletion cmd/istioctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
16 changes: 8 additions & 8 deletions cmd/istioctl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 9aef432

Please sign in to comment.