From f8f91334d44f6f2e15d684bb094e37f1deb67896 Mon Sep 17 00:00:00 2001 From: Sami Alajrami Date: Sat, 3 Mar 2018 12:35:45 +0100 Subject: [PATCH 1/3] fixing #19 --- decision_maker.go | 2 +- helm_helpers.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/decision_maker.go b/decision_maker.go index 2705ca7e..6ee915d5 100644 --- a/decision_maker.go +++ b/decision_maker.go @@ -268,7 +268,7 @@ func logDecision(decision string) { } -// extractChartName extracts the Helm chart name from full chart name. +// extractChartName extracts the Helm chart name from full chart name in the desired state. // example: it extracts "chartY" from "repoX/chartY" func extractChartName(releaseChart string) string { diff --git a/helm_helpers.go b/helm_helpers.go index 8533856f..65a70b1f 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -97,13 +97,15 @@ 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 "stable/jenkins-0.9.0" and this functions will extract "stable/jenkins" from it. +// example: getReleaseChart() returns "jenkins-0.9.0" and this functions will extract "jenkins" from it. func getReleaseChartName(releaseName string) string { - return strings.TrimSpace(strings.Split(getReleaseChart(releaseName), "-")[0]) + chart := getReleaseChart(releaseName) + 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(). -// example: getReleaseChart() returns "stable/jenkins-0.9.0" and this functions will extract "0.9.0" from it. +// example: getReleaseChart() returns "jenkins-0.9.0" and this functions will extract "0.9.0" from it. func getReleaseChartVersion(releaseName string) string { return strings.TrimSpace(strings.Split(getReleaseChart(releaseName), "-")[1]) } From 5d94346e6311be4f8ee05126d4dcd7caadae02e4 Mon Sep 17 00:00:00 2001 From: Sami Alajrami Date: Sat, 3 Mar 2018 12:39:21 +0100 Subject: [PATCH 2/3] fixing #20 --- decision_maker.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/decision_maker.go b/decision_maker.go index 6ee915d5..5bdcd4c1 100644 --- a/decision_maker.go +++ b/decision_maker.go @@ -328,6 +328,11 @@ func checkNamespaceDefined(ns string) bool { // returns true if a release is protected, false otherwise func isProtected(r release) bool { + // if the release does not exist in the cluster, it is not protected + if !helmReleaseExists("", r.Name, "all") { + return false + } + if getCurrentNamespaceProtection(r) { return true } From 1da063cb7786edf255e25f094ed5dea75762fe6e Mon Sep 17 00:00:00 2001 From: Sami Alajrami Date: Sat, 3 Mar 2018 13:08:45 +0100 Subject: [PATCH 3/3] fixing version checks for charts with '-' in their names. --- helm_helpers.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helm_helpers.go b/helm_helpers.go index 65a70b1f..b293bf3b 100644 --- a/helm_helpers.go +++ b/helm_helpers.go @@ -107,7 +107,9 @@ func getReleaseChartName(releaseName string) string { // getReleaseChartVersion extracts and returns the Helm chart version from the chart info retrieved by getReleaseChart(). // example: getReleaseChart() returns "jenkins-0.9.0" and this functions will extract "0.9.0" from it. func getReleaseChartVersion(releaseName string) string { - return strings.TrimSpace(strings.Split(getReleaseChart(releaseName), "-")[1]) + chart := getReleaseChart(releaseName) + runes := []rune(chart) + return string(runes[strings.LastIndexByte(chart, '-')+1 : len(chart)]) } // getReleaseStatus returns the output of Helm status command for a release.