diff --git a/cmd/helm/helm.go b/cmd/helm/helm.go index b30d6b011..2c3c9e401 100644 --- a/cmd/helm/helm.go +++ b/cmd/helm/helm.go @@ -67,7 +67,7 @@ func main() { actionConfig := new(action.Configuration) cmd := newRootCmd(actionConfig, os.Stdout, os.Args[1:]) - if err := actionConfig.Init(settings, false, os.Getenv("HELM_DRIVER"), debug); err != nil { + if err := actionConfig.Init(settings.RESTClientGetter(), settings.Namespace(), os.Getenv("HELM_DRIVER"), debug); err != nil { debug("%+v", err) os.Exit(1) } diff --git a/cmd/helm/list.go b/cmd/helm/list.go index 2200c153b..f80a81b9a 100644 --- a/cmd/helm/list.go +++ b/cmd/helm/list.go @@ -70,7 +70,7 @@ func newListCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { Args: require.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { if client.AllNamespaces { - if err := cfg.Init(settings, true, os.Getenv("HELM_DRIVER"), debug); err != nil { + if err := cfg.Init(settings.RESTClientGetter(), "", os.Getenv("HELM_DRIVER"), debug); err != nil { return err } } diff --git a/pkg/action/action.go b/pkg/action/action.go index 653a57830..48d6bf742 100644 --- a/pkg/action/action.go +++ b/pkg/action/action.go @@ -22,13 +22,13 @@ import ( "github.com/pkg/errors" "k8s.io/apimachinery/pkg/api/meta" + "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/client-go/discovery" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" "helm.sh/helm/v3/internal/experimental/registry" "helm.sh/helm/v3/pkg/chartutil" - "helm.sh/helm/v3/pkg/cli" "helm.sh/helm/v3/pkg/kube" "helm.sh/helm/v3/pkg/release" "helm.sh/helm/v3/pkg/storage" @@ -210,9 +210,7 @@ func (c *Configuration) recordRelease(r *release.Release) { } // InitActionConfig initializes the action configuration -func (c *Configuration) Init(envSettings *cli.EnvSettings, allNamespaces bool, helmDriver string, log DebugLog) error { - getter := envSettings.RESTClientGetter() - +func (c *Configuration) Init(getter genericclioptions.RESTClientGetter, namespace string, helmDriver string, log DebugLog) error { kc := kube.New(getter) kc.Log = log @@ -220,10 +218,6 @@ func (c *Configuration) Init(envSettings *cli.EnvSettings, allNamespaces bool, h if err != nil { return err } - var namespace string - if !allNamespaces { - namespace = envSettings.Namespace() - } var store *storage.Storage switch helmDriver {