From 657b23f672c2481a71b3e8c9c6a18475c6171b21 Mon Sep 17 00:00:00 2001 From: Janis Meybohm Date: Wed, 5 Aug 2020 18:25:41 +0200 Subject: [PATCH] Detect kubeconfig as known argument in plugin invocations --kubeconfig is not detected as a known argument on plugin invocations. This means it depends on the order or arguments if helm picks it up or not which might not be under users control (for me in case of helmfile calling "helm diff"). Signed-off-by: Janis Meybohm --- cmd/helm/load_plugins.go | 2 +- cmd/helm/plugin_test.go | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cmd/helm/load_plugins.go b/cmd/helm/load_plugins.go index a3e4299a8..62a48d728 100644 --- a/cmd/helm/load_plugins.go +++ b/cmd/helm/load_plugins.go @@ -128,7 +128,7 @@ func loadPlugins(baseCmd *cobra.Command, out io.Writer) { func manuallyProcessArgs(args []string) ([]string, []string) { known := []string{} unknown := []string{} - kvargs := []string{"--host", "--kube-context", "--home", "--tiller-namespace"} + kvargs := []string{"--host", "--kube-context", "--home", "--tiller-namespace", "--kubeconfig"} knownArg := func(a string) bool { for _, pre := range kvargs { if strings.HasPrefix(a, pre+"=") { diff --git a/cmd/helm/plugin_test.go b/cmd/helm/plugin_test.go index 2d06c3797..75e049d6b 100644 --- a/cmd/helm/plugin_test.go +++ b/cmd/helm/plugin_test.go @@ -34,6 +34,7 @@ func TestManuallyProcessArgs(t *testing.T) { "--debug", "--foo", "bar", "--host", "example.com", + "--kubeconfig=/home/foo", "--kube-context", "test1", "--home=/tmp", "--tiller-namespace=hello", @@ -41,7 +42,7 @@ func TestManuallyProcessArgs(t *testing.T) { } expectKnown := []string{ - "--debug", "--host", "example.com", "--kube-context", "test1", "--home=/tmp", "--tiller-namespace=hello", + "--debug", "--host", "example.com", "--kubeconfig=/home/foo", "--kube-context", "test1", "--home=/tmp", "--tiller-namespace=hello", } expectUnknown := []string{