Skip to content

Commit

Permalink
fixed the rollback revision number param.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Alajrami committed Nov 19, 2017
1 parent 94b7c13 commit 963d008
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion decision_maker.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func inspectRollbackScenario(namespace string, r release) {

cmd := command{
Cmd: "bash",
Args: []string{"-c", "helm rollback " + releaseName},
Args: []string{"-c", "helm rollback " + releaseName + " " + getReleaseRevision(releaseName, "deleted")},
Description: "rolling back release [ " + releaseName + " ]",
}
outcome.addCommand(cmd)
Expand Down
19 changes: 18 additions & 1 deletion helm_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,24 @@ func getReleaseChart(releaseName string) string {
return strings.Fields(line)[8] // 8 is the position of chart details in helm ls output
}
log.Fatal("ERROR: seems release [ " + releaseName + " ] does not exist.")
os.Exit(1)

return ""
}

// getReleaseRevision returns the revision number for a release (if it exists)
func getReleaseRevision(releaseName string, state string) string {
cmd := command{
Cmd: "bash",
Args: []string{"-c", "helm list " + releaseName + " --" + state},
Description: "inspecting the release revision for : " + releaseName,
}
exitCode, result := cmd.exec(debug)

if exitCode == 0 {
line := strings.Split(result, "\n")[1]
return strings.Fields(line)[1] // 1 is the position of revision number in helm ls output
}
log.Fatal("ERROR: seems release [ " + releaseName + " ] does not exist.")

return ""
}
Expand Down

0 comments on commit 963d008

Please sign in to comment.