Skip to content

Commit

Permalink
Merging fixes for #19 and #20
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Alajrami committed Mar 3, 2018
2 parents 42a5165 + 1da063c commit 5e85cf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion decision_maker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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
}
Expand Down
12 changes: 8 additions & 4 deletions helm_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,19 @@ 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])
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.
Expand Down

0 comments on commit 5e85cf1

Please sign in to comment.