From 2a931b84ab85be96e224ee827d67de7641cea141 Mon Sep 17 00:00:00 2001 From: Thorben Below <56894536+thorbenbelow@users.noreply.github.com> Date: Fri, 16 Aug 2024 18:15:44 +0200 Subject: [PATCH] Fix: ensure correct ns for helm actions (#2652) Signed-off-by: Thorben Below <56894536+thorbenbelow@users.noreply.github.com> --- internal/dao/helm_chart.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/internal/dao/helm_chart.go b/internal/dao/helm_chart.go index 2efe9f6b..819a9c63 100644 --- a/internal/dao/helm_chart.go +++ b/internal/dao/helm_chart.go @@ -124,7 +124,6 @@ func (h *HelmChart) Delete(_ context.Context, path string, _ *metav1.DeletionPro func (h *HelmChart) Uninstall(path string, keepHist bool) error { ns, n := client.Namespaced(path) flags := h.Client().Config().Flags() - flags.Namespace = &ns cfg, err := ensureHelmConfig(flags, ns) if err != nil { return err @@ -145,8 +144,21 @@ func (h *HelmChart) Uninstall(path string, keepHist bool) error { // ensureHelmConfig return a new configuration. func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) { + settings := &genericclioptions.ConfigFlags{ + Namespace: &ns, + Context: flags.Context, + BearerToken: flags.BearerToken, + APIServer: flags.APIServer, + CAFile: flags.CAFile, + KubeConfig: flags.KubeConfig, + Impersonate: flags.Impersonate, + Insecure: flags.Insecure, + TLSServerName: flags.TLSServerName, + ImpersonateGroup: flags.ImpersonateGroup, + WrapConfigFn: flags.WrapConfigFn, + } cfg := new(action.Configuration) - err := cfg.Init(flags, ns, os.Getenv("HELM_DRIVER"), helmLogger) + err := cfg.Init(settings, ns, os.Getenv("HELM_DRIVER"), helmLogger) return cfg, err }