Skip to content

Commit

Permalink
Fix: ensure correct ns for helm actions (derailed#2652)
Browse files Browse the repository at this point in the history
Signed-off-by: Thorben Below <56894536+thorbenbelow@users.noreply.github.com>
  • Loading branch information
thorbenbelow authored and uozalp committed Sep 2, 2024
1 parent c73b97c commit 6aad41d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions internal/dao/helm_chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Expand Down

0 comments on commit 6aad41d

Please sign in to comment.