Pass --keep-history when so instructed [#24]

This commit is contained in:
Erin Call
2020-01-02 10:58:58 -08:00
parent 7d750f097d
commit 17724e7015
7 changed files with 32 additions and 7 deletions

View File

@@ -6,9 +6,10 @@ import (
// Uninstall is an execution step that calls `helm uninstall` when executed.
type Uninstall struct {
Release string
DryRun bool
cmd cmd
Release string
DryRun bool
KeepHistory bool
cmd cmd
}
// Execute executes the `helm uninstall` command.
@@ -36,6 +37,9 @@ func (u *Uninstall) Prepare(cfg Config) error {
if u.DryRun {
args = append(args, "--dry-run")
}
if u.KeepHistory {
args = append(args, "--keep-history")
}
args = append(args, u.Release)

View File

@@ -81,6 +81,21 @@ func (suite *UninstallTestSuite) TestPrepareDryRunFlag() {
suite.Equal(expected, suite.actualArgs)
}
func (suite *UninstallTestSuite) TestPrepareKeepHistoryFlag() {
u := Uninstall{
Release: "perturbator_sentient",
KeepHistory: true,
}
cfg := Config{}
suite.mockCmd.EXPECT().Stdout(gomock.Any()).AnyTimes()
suite.mockCmd.EXPECT().Stderr(gomock.Any()).AnyTimes()
suite.NoError(u.Prepare(cfg))
expected := []string{"uninstall", "--keep-history", "perturbator_sentient"}
suite.Equal(expected, suite.actualArgs)
}
func (suite *UninstallTestSuite) TestPrepareNamespaceFlag() {
u := Uninstall{
Release: "carly_simon_run_away_with_me",