From 910bbd487bfb8c52dc0f41c3c0c593df31b2cb87 Mon Sep 17 00:00:00 2001 From: daplho Date: Thu, 3 May 2018 13:47:16 -0700 Subject: [PATCH 1/6] fixing compare here as NAMESPACE comes with extra space at the end of each line --- helm_helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm_helpers.go b/helm_helpers.go index 39236287..e0731099 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -61,7 +61,7 @@ func buildState() { lines := strings.Split(getAllReleases(), "\n") for i := 0; i < len(lines); i++ { - if lines[i] == "" || (strings.HasPrefix(lines[i], "NAME") && strings.HasSuffix(lines[i], "NAMESPACE")) { + if lines[i] == "" || (strings.HasPrefix(strings.TrimSpace(lines[i]), "NAME") && strings.HasSuffix(strings.TrimSpace(lines[i]), "NAMESPACE")) { continue } r, _ := strconv.Atoi(strings.Fields(lines[i])[1]) From a28fd3d94b71f0722bdb3dcb8841cddc2a260613 Mon Sep 17 00:00:00 2001 From: daplho Date: Thu, 3 May 2018 16:34:56 -0700 Subject: [PATCH 2/6] decision maker will decide to reInstall if Version has dashes within the name as well as between the name and the version --- decision_maker.go | 4 ++-- helm_helpers.go | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/decision_maker.go b/decision_maker.go index a8cfe3e9..fc8a8b6a 100644 --- a/decision_maker.go +++ b/decision_maker.go @@ -192,12 +192,12 @@ func inspectUpgradeScenario(namespace string, r *release) { releaseName := r.Name if getReleaseNamespace(releaseName) == namespace { - if extractChartName(r.Chart) == getReleaseChartName(releaseName) && r.Version != getReleaseChartVersion(releaseName) { + if extractChartName(r.Chart) == getReleaseChartName(releaseName, r.Version) && r.Version != getReleaseChartVersion(releaseName) { // upgrade upgradeRelease(r) logDecision("DECISION: release [ "+releaseName+" ] is desired to be upgraded. Planing this for you!", r.Priority) - } else if extractChartName(r.Chart) != getReleaseChartName(releaseName) { + } else if extractChartName(r.Chart) != getReleaseChartName(releaseName, r.Version) { reInstallRelease(namespace, r) logDecision("DECISION: release [ "+releaseName+" ] is desired to use a new Chart [ "+r.Chart+ " ]. I am planning a purge delete of the current release and will install it with the new chart in namespace [[ "+ diff --git a/helm_helpers.go b/helm_helpers.go index e0731099..2106feb4 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -189,10 +189,9 @@ func getReleaseRevision(releaseName string, state string) string { // getReleaseChartName extracts and returns the Helm chart name from the chart info retrieved by getReleaseChart(). // example: getReleaseChart() returns "jenkins-0.9.0" and this functions will extract "jenkins" from it. -func getReleaseChartName(releaseName string) string { +func getReleaseChartName(releaseName string, version string) string { chart := getReleaseChart(releaseName) - runes := []rune(chart) - return string(runes[0:strings.LastIndexByte(chart, '-')]) + return strings.TrimSuffix(strings.TrimSuffix(chart, version), "-") } // getReleaseChartVersion extracts and returns the Helm chart version from the chart info retrieved by getReleaseChart(). From 727c4b138a2a01734f8e076782b1ea1454aefbfd Mon Sep 17 00:00:00 2001 From: daplho Date: Thu, 3 May 2018 16:40:09 -0700 Subject: [PATCH 3/6] Revert "decision maker will decide to reInstall if Version has dashes within the name as well as between the name and the version" This reverts commit a28fd3d94b71f0722bdb3dcb8841cddc2a260613. --- decision_maker.go | 4 ++-- helm_helpers.go | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/decision_maker.go b/decision_maker.go index fc8a8b6a..a8cfe3e9 100644 --- a/decision_maker.go +++ b/decision_maker.go @@ -192,12 +192,12 @@ func inspectUpgradeScenario(namespace string, r *release) { releaseName := r.Name if getReleaseNamespace(releaseName) == namespace { - if extractChartName(r.Chart) == getReleaseChartName(releaseName, r.Version) && r.Version != getReleaseChartVersion(releaseName) { + if extractChartName(r.Chart) == getReleaseChartName(releaseName) && r.Version != getReleaseChartVersion(releaseName) { // upgrade upgradeRelease(r) logDecision("DECISION: release [ "+releaseName+" ] is desired to be upgraded. Planing this for you!", r.Priority) - } else if extractChartName(r.Chart) != getReleaseChartName(releaseName, r.Version) { + } else if extractChartName(r.Chart) != getReleaseChartName(releaseName) { reInstallRelease(namespace, r) logDecision("DECISION: release [ "+releaseName+" ] is desired to use a new Chart [ "+r.Chart+ " ]. I am planning a purge delete of the current release and will install it with the new chart in namespace [[ "+ diff --git a/helm_helpers.go b/helm_helpers.go index 2106feb4..e0731099 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -189,9 +189,10 @@ func getReleaseRevision(releaseName string, state string) string { // getReleaseChartName extracts and returns the Helm chart name from the chart info retrieved by getReleaseChart(). // example: getReleaseChart() returns "jenkins-0.9.0" and this functions will extract "jenkins" from it. -func getReleaseChartName(releaseName string, version string) string { +func getReleaseChartName(releaseName string) string { chart := getReleaseChart(releaseName) - return strings.TrimSuffix(strings.TrimSuffix(chart, version), "-") + runes := []rune(chart) + return string(runes[0:strings.LastIndexByte(chart, '-')]) } // getReleaseChartVersion extracts and returns the Helm chart version from the chart info retrieved by getReleaseChart(). From 2cba694dc6daab6620d5ed63abf57a2a35d1d466 Mon Sep 17 00:00:00 2001 From: daplho Date: Thu, 3 May 2018 16:50:34 -0700 Subject: [PATCH 4/6] decision maker will erroneously decide to reinstall if Version has dashes within the name as well as between the name and the version --- helm_helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm_helpers.go b/helm_helpers.go index e0731099..2b046874 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -192,7 +192,7 @@ func getReleaseRevision(releaseName string, state string) string { func getReleaseChartName(releaseName string) string { chart := getReleaseChart(releaseName) runes := []rune(chart) - return string(runes[0:strings.LastIndexByte(chart, '-')]) + return string(runes[0:strings.LastIndexByte(chart[0:strings.IndexByte(chart, '.')], '-')]) } // getReleaseChartVersion extracts and returns the Helm chart version from the chart info retrieved by getReleaseChart(). From 3acaf981db141939c1a60f78150a60f4008e2bc3 Mon Sep 17 00:00:00 2001 From: Sami Alajrami Date: Sun, 6 May 2018 18:19:52 +0200 Subject: [PATCH 5/6] bumping version --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index c706f677..47b5ef16 100644 --- a/main.go +++ b/main.go @@ -19,7 +19,7 @@ var verbose bool var nsOverride string var checkCleanup bool var skipValidation bool -var version = "v1.2.0-rc1" +var version = "v1.2.0-rc2" func main() { From d4cbb68cf76a5062bb23ff50b5d3b355eaa86188 Mon Sep 17 00:00:00 2001 From: Sami Alajrami Date: Sun, 6 May 2018 18:21:00 +0200 Subject: [PATCH 6/6] trimming spaces in the if statement when getting releases from a specific tiller. --- helm_helpers.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helm_helpers.go b/helm_helpers.go index 2b046874..aac606b5 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -47,7 +47,7 @@ func getTillerReleases(tillerNS string) string { // appending tiller-namespace to each release found lines := strings.Split(result, "\n") for i, l := range lines { - if l != "" && !strings.HasPrefix(l, "NAME") && !strings.HasSuffix(l, "NAMESPACE") { + if l != "" && !strings.HasPrefix(strings.TrimSpace(l), "NAME") && !strings.HasSuffix(strings.TrimSpace(l), "NAMESPACE") { lines[i] = strings.TrimSuffix(l, "\n") + " " + tillerNS } }