Fix: ensure correct ns for helm actions (#2652)

Signed-off-by: Thorben Below <56894536+thorbenbelow@users.noreply.github.com>
mine
Thorben Below 2024-08-16 18:15:44 +02:00 committed by GitHub
parent 4b2111e327
commit 2a931b84ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 2 deletions

View File

@ -124,7 +124,6 @@ func (h *HelmChart) Delete(_ context.Context, path string, _ *metav1.DeletionPro
func (h *HelmChart) Uninstall(path string, keepHist bool) error { func (h *HelmChart) Uninstall(path string, keepHist bool) error {
ns, n := client.Namespaced(path) ns, n := client.Namespaced(path)
flags := h.Client().Config().Flags() flags := h.Client().Config().Flags()
flags.Namespace = &ns
cfg, err := ensureHelmConfig(flags, ns) cfg, err := ensureHelmConfig(flags, ns)
if err != nil { if err != nil {
return err return err
@ -145,8 +144,21 @@ func (h *HelmChart) Uninstall(path string, keepHist bool) error {
// ensureHelmConfig return a new configuration. // ensureHelmConfig return a new configuration.
func ensureHelmConfig(flags *genericclioptions.ConfigFlags, ns string) (*action.Configuration, error) { 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) 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 return cfg, err
} }