Repository: roboll/helmfile
Pull request #1003 (2019-11-28 15:13:17)

Fix typos
Just fixing typos in the README


Patch:
diff --git a/README.md b/README.md
index 46aa4d6..e87aebb 100644
--- a/README.md
+++ b/README.md
@@ -74,6 +74,7 @@ helmDefaults:
   tillerNamespace: tiller-namespace  #dedicated default key for tiller-namespace
   tillerless: false                  #dedicated default key for tillerless
   kubeContext: kube-context          #dedicated default key for kube-context (--kube-context)
+  cleanup-on-fail: false             #dedicated default key for helm flag --cleanup-on-fail
   # additional and global args passed to helm
   args:
     - "--set k=v"
@@ -157,6 +158,8 @@ releases:
     installed: true
     # restores previous state in case of failed release
     atomic: true
+    # when true, cleans up any new resources created during a failed release
+    cleanup-on-fail: false
     # name of the tiller namespace
     tillerNamespace: vault
     # if true, will use the helm-tiller plugin
@@ -767,7 +770,7 @@ For the following example, `helmfile [sync|apply]` installs releases in this ord
 
 Note that all the releases in a same group is installed concurrently. That is, myapp1 and myapp2 are installed concurrently.
 
-On `helmdile [delete|destroy]`, deleations happen in the reverse order.
+On `helmfile [delete|destroy]`, deletions happen in the reverse order.
 
 That is, `myapp1` and `myapp2` are deleted first, then `servicemesh`, and finally `logging`.
 
diff --git a/pkg/state/state.go b/pkg/state/state.go
index fbc2258..a1df6a3 100644
--- a/pkg/state/state.go
+++ b/pkg/state/state.go
@@ -101,6 +101,8 @@ type HelmSpec struct {
 	Force bool `yaml:"force"`
 	// Atomic, when set to true, restore previous state in case of a failed install/upgrade attempt
 	Atomic bool `yaml:"atomic"`
+	// CleanupOnFail, when set to true, the --cleanup-on-fail helm flag is passed to the upgrade command
+	CleanupOnFail bool `yaml:"cleanup-on-fail,omitempty"`
 
 	TLS       bool   `yaml:"tls"`
 	TLSCACert string `yaml:"tlsCACert,omitempty"`
@@ -139,6 +141,8 @@ type ReleaseSpec struct {
 	Installed *bool `yaml:"installed,omitempty"`
 	// Atomic, when set to true, restore previous state in case of a failed install/upgrade attempt
 	Atomic *bool `yaml:"atomic,omitempty"`
+	// CleanupOnFail, when set to true, the --cleanup-on-fail helm flag is passed to the upgrade command
+	CleanupOnFail *bool `yaml:"cleanup-on-fail,omitempty"`
 
 	// MissingFileHandler is set to either "Error" or "Warn". "Error" instructs helmfile to fail when unable to find a values or secrets file. When "Warn", it prints the file and continues.
 	// The default value for MissingFileHandler is "Error".
@@ -1546,6 +1550,10 @@ func (st *HelmState) flagsForUpgrade(helm helmexec.Interface, release *ReleaseSp
 		flags = append(flags, "--atomic")
 	}
 
+	if release.CleanupOnFail != nil && *release.CleanupOnFail || release.CleanupOnFail == nil && st.HelmDefaults.CleanupOnFail {
+		flags = append(flags, "--cleanup-on-fail")
+	}
+
 	flags = st.appendConnectionFlags(flags, release)
 
 	var err error


Test patch:
diff --git a/pkg/state/state_test.go b/pkg/state/state_test.go
index 3d00d20..86891bd 100644
--- a/pkg/state/state_test.go
+++ b/pkg/state/state_test.go
@@ -448,6 +448,58 @@ func TestHelmState_flagsForUpgrade(t *testing.T) {
 				"--namespace", "test-namespace",
 			},
 		},
+		{
+			name: "cleanup-on-fail",
+			defaults: HelmSpec{
+				CleanupOnFail: false,
+			},
+			release: &ReleaseSpec{
+				Chart:         "test/chart",
+				Version:       "0.1",
+				CleanupOnFail: &enable,
+				Name:          "test-charts",
+				Namespace:     "test-namespace",
+			},
+			want: []string{
+				"--version", "0.1",
+				"--cleanup-on-fail",
+				"--namespace", "test-namespace",
+			},
+		},
+		{
+			name: "cleanup-on-fail-override-default",
+			defaults: HelmSpec{
+				CleanupOnFail: true,
+			},
+			release: &ReleaseSpec{
+				Chart:         "test/chart",
+				Version:       "0.1",
+				CleanupOnFail: &disable,
+				Name:          "test-charts",
+				Namespace:     "test-namespace",
+			},
+			want: []string{
+				"--version", "0.1",
+				"--namespace", "test-namespace",
+			},
+		},
+		{
+			name: "cleanup-on-fail-from-default",
+			defaults: HelmSpec{
+				CleanupOnFail: true,
+			},
+			release: &ReleaseSpec{
+				Chart:     "test/chart",
+				Version:   "0.1",
+				Name:      "test-charts",
+				Namespace: "test-namespace",
+			},
+			want: []string{
+				"--version", "0.1",
+				"--cleanup-on-fail",
+				"--namespace", "test-namespace",
+			},
+		},
 		{
 			name:     "tiller",
 			defaults: HelmSpec{},