From fa95e0dd920fa953cb1c7eea245b2dbf6a735c15 Mon Sep 17 00:00:00 2001 From: Patrick Valsecchi Date: Tue, 2 Apr 2019 11:51:11 +0200 Subject: [PATCH] Allow the same release name on different tillerNamespaces (#529) Closes #528 --- pkg/app/app.go | 13 ++++++++++--- pkg/app/app_test.go | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index 582abe13..eb06f17e 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -202,13 +202,20 @@ func (a *App) VisitDesiredStatesWithReleasesFiltered(fileOrDir string, converge } } - releaseNameCounts := map[string]int{} + type Key struct { + TillerNamespace, Name string + } + releaseNameCounts := map[Key]int{} for _, r := range st.Releases { - releaseNameCounts[r.Name]++ + tillerNamespace := st.HelmDefaults.TillerNamespace + if r.TillerNamespace != "" { + tillerNamespace = r.TillerNamespace + } + releaseNameCounts[Key{tillerNamespace, r.Name}]++ } for name, c := range releaseNameCounts { if c > 1 { - return false, []error{fmt.Errorf("duplicate release \"%s\" found: there were %d releases named \"%s\" matching specified selector", name, c, name)} + return false, []error{fmt.Errorf("duplicate release \"%s\" found in \"%s\": there were %d releases named \"%s\" matching specified selector", name.Name, name.TillerNamespace, c, name.Name)} } } diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go index ac220c5c..81bcc09d 100644 --- a/pkg/app/app_test.go +++ b/pkg/app/app_test.go @@ -247,6 +247,8 @@ releases: chart: stable/prometheus `, "/path/to/helmfile.d/b.yaml": ` +helmDefaults: + tillerNamespace: zoo releases: - name: grafana chart: stable/grafana @@ -258,6 +260,16 @@ releases: chart: charts/foo labels: duplicated: yes +- name: bar + chart: charts/foo + tillerNamespace: bar1 + labels: + duplicatedOK: yes +- name: bar + chart: charts/foo + tillerNamespace: bar2 + labels: + duplicatedOK: yes `, } @@ -272,7 +284,8 @@ releases: {label: "name!=", expectedCount: 0, expectErr: true, errMsg: "failed processing /path/to/helmfile.d/a1.yaml: Malformed label: name!=. Expected label in form k=v or k!=v"}, {label: "name", expectedCount: 0, expectErr: true, errMsg: "failed processing /path/to/helmfile.d/a1.yaml: Malformed label: name. Expected label in form k=v or k!=v"}, // See https://github.com/roboll/helmfile/issues/193 - {label: "duplicated=yes", expectedCount: 0, expectErr: true, errMsg: "failed processing /path/to/helmfile.d/b.yaml: duplicate release \"foo\" found: there were 2 releases named \"foo\" matching specified selector"}, + {label: "duplicated=yes", expectedCount: 0, expectErr: true, errMsg: "failed processing /path/to/helmfile.d/b.yaml: duplicate release \"foo\" found in \"zoo\": there were 2 releases named \"foo\" matching specified selector"}, + {label: "duplicatedOK=yes", expectedCount: 2, expectErr: false}, } for _, testcase := range testcases {