mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Merge pull request #7065 from VilledeMontreal/fix/equalNamespacePlugin
v3: -n= flag is mistakenly being passed to plugins
This commit is contained in:
commit
1e237eac2b
2 changed files with 26 additions and 3 deletions
|
|
@ -127,7 +127,7 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) {
|
|||
func manuallyProcessArgs(args []string) ([]string, []string) {
|
||||
known := []string{}
|
||||
unknown := []string{}
|
||||
kvargs := []string{"--kube-context", "--namespace", "--kubeconfig", "--registry-config", "--repository-cache", "--repository-config"}
|
||||
kvargs := []string{"--kube-context", "--namespace", "-n", "--kubeconfig", "--registry-config", "--repository-cache", "--repository-config"}
|
||||
knownArg := func(a string) bool {
|
||||
for _, pre := range kvargs {
|
||||
if strings.HasPrefix(a, pre+"=") {
|
||||
|
|
@ -136,11 +136,21 @@ func manuallyProcessArgs(args []string) ([]string, []string) {
|
|||
}
|
||||
return false
|
||||
}
|
||||
|
||||
isKnown := func(v string) string {
|
||||
for _, i := range kvargs {
|
||||
if i == v {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
for i := 0; i < len(args); i++ {
|
||||
switch a := args[i]; a {
|
||||
case "--debug":
|
||||
known = append(known, a)
|
||||
case "--kube-context", "--namespace", "-n", "--kubeconfig", "--registry-config", "--repository-cache", "--repository-config":
|
||||
case isKnown(a):
|
||||
known = append(known, a, args[i+1])
|
||||
i++
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -30,14 +30,27 @@ func TestManuallyProcessArgs(t *testing.T) {
|
|||
"--debug",
|
||||
"--foo", "bar",
|
||||
"--kubeconfig=/home/foo",
|
||||
"--kubeconfig", "/home/foo",
|
||||
"--kube-context=test1",
|
||||
"--kube-context", "test1",
|
||||
"-n=test2",
|
||||
"-n", "test2",
|
||||
"--namespace=test2",
|
||||
"--namespace", "test2",
|
||||
"--home=/tmp",
|
||||
"command",
|
||||
}
|
||||
|
||||
expectKnown := []string{
|
||||
"--debug", "--kubeconfig=/home/foo", "--kube-context", "test1", "-n", "test2",
|
||||
"--debug",
|
||||
"--kubeconfig=/home/foo",
|
||||
"--kubeconfig", "/home/foo",
|
||||
"--kube-context=test1",
|
||||
"--kube-context", "test1",
|
||||
"-n=test2",
|
||||
"-n", "test2",
|
||||
"--namespace=test2",
|
||||
"--namespace", "test2",
|
||||
}
|
||||
|
||||
expectUnknown := []string{
|
||||
|
|
|
|||
Loading…
Reference in a new issue