From 60702846f1addb07de91a31145de9dc0e2a9d5bb Mon Sep 17 00:00:00 2001 From: zchenyu Date: Thu, 4 May 2023 10:57:56 -0700 Subject: [PATCH] Update chartExists to work with empty namespace and namespace set to default --- client.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 96925b8c..0d557d42 100644 --- a/client.go +++ b/client.go @@ -780,8 +780,16 @@ func (c *HelmClient) chartExists(spec *ChartSpec) (bool, error) { return false, err } + normalizeNamespace := func(s string) string { + if s == "" { + return "default" + } + return s + } + expectedNamespace := normalizeNamespace(spec.Namespace) + for _, r := range releases { - if r.Name == spec.ReleaseName && r.Namespace == spec.Namespace { + if r.Name == spec.ReleaseName && normalizeNamespace(r.Namespace) == expectedNamespace { return true, nil } }