Skip to content

Commit 005066b

Browse files
authored
Merge pull request #26 from fluxcd/enhancement/uninstall-keep-history
Support KeepHistory flag for Helm uninstall action
2 parents afe255e + fd8d83d commit 005066b

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

api/v2alpha1/helmrelease_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,11 @@ type Uninstall struct {
317317
// DisableHooks prevents hooks from running during the Helm rollback action.
318318
// +optional
319319
DisableHooks bool `json:"disableHooks,omitempty"`
320+
321+
// KeepHistory tells Helm to remove all associated resources and mark the release as
322+
// deleted, but retain the release history.
323+
// +optional
324+
KeepHistory bool `json:"keepHistory,omitempty"`
320325
}
321326

322327
// GetTimeout returns the configured timeout for the Helm uninstall action,

config/crd/bases/helm.fluxcd.io_helmreleases.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ spec:
208208
description: DisableHooks prevents hooks from running during the
209209
Helm rollback action.
210210
type: boolean
211+
keepHistory:
212+
description: KeepHistory tells Helm to remove all associated resources
213+
and mark the release as deleted, but retain the release history.
214+
type: boolean
211215
timeout:
212216
description: Timeout is the time to wait for any individual Kubernetes
213217
operation (like Jobs for hooks) during the performance of a Helm

controllers/helmrelease_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ func uninstall(cfg *action.Configuration, hr v2.HelmRelease) error {
555555
uninstall := action.NewUninstall(cfg)
556556
uninstall.Timeout = hr.Spec.Uninstall.GetTimeout(hr.GetTimeout()).Duration
557557
uninstall.DisableHooks = hr.Spec.Uninstall.DisableHooks
558+
uninstall.KeepHistory = hr.Spec.Uninstall.KeepHistory
558559

559560
_, err := uninstall.Run(hr.GetReleaseName())
560561
return err

docs/api/helmrelease.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,19 @@ bool
11261126
<p>DisableHooks prevents hooks from running during the Helm rollback action.</p>
11271127
</td>
11281128
</tr>
1129+
<tr>
1130+
<td>
1131+
<code>keepHistory</code><br>
1132+
<em>
1133+
bool
1134+
</em>
1135+
</td>
1136+
<td>
1137+
<em>(Optional)</em>
1138+
<p>KeepHistory tells Helm to remove all associated resources and mark the release as
1139+
deleted, but retain the release history.</p>
1140+
</td>
1141+
</tr>
11291142
</tbody>
11301143
</table>
11311144
</div>

docs/spec/v2alpha1/helmreleases.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ type Uninstall struct {
233233
// DisableHooks prevents hooks from running during the Helm rollback action.
234234
// +optional
235235
DisableHooks bool `json:"disableHooks,omitempty"`
236+
237+
// KeepHistory tells Helm to remove all associated resources and mark the release
238+
// as deleted, but retain the release history.
239+
// +optional
240+
KeepHistory bool `json:"keepHistory,omitempty"`
236241
}
237242
```
238243

0 commit comments

Comments
 (0)