diff --git a/api/v2beta2/helmrelease_types.go b/api/v2beta2/helmrelease_types.go index 77da07aa7..936a9101a 100644 --- a/api/v2beta2/helmrelease_types.go +++ b/api/v2beta2/helmrelease_types.go @@ -801,6 +801,13 @@ type Uninstall struct { // a Helm uninstall is performed. // +optional DisableWait bool `json:"disableWait,omitempty"` + + // DeletionPropagation specifies the deletion propagation policy when + // a Helm uninstall is performed. + // +kubebuilder:default=background + // +kubebuilder:validation:Enum=background;foreground;orphan + // +optional + DeletionPropagation *string `json:"deletionPropagation,omitempty"` } // GetTimeout returns the configured timeout for the Helm uninstall action, or @@ -812,6 +819,15 @@ func (in Uninstall) GetTimeout(defaultTimeout metav1.Duration) metav1.Duration { return *in.Timeout } +// GetDeletionPropagation returns the configured deletion propagation policy +// for the Helm uninstall action, or 'background'. +func (in Uninstall) GetDeletionPropagation() string { + if in.DeletionPropagation == nil { + return "background" + } + return *in.DeletionPropagation +} + // HelmReleaseInfo holds the status information for a Helm release as performed // by the controller. type HelmReleaseInfo struct { diff --git a/api/v2beta2/zz_generated.deepcopy.go b/api/v2beta2/zz_generated.deepcopy.go index 25e118848..31282f767 100644 --- a/api/v2beta2/zz_generated.deepcopy.go +++ b/api/v2beta2/zz_generated.deepcopy.go @@ -558,6 +558,11 @@ func (in *Uninstall) DeepCopyInto(out *Uninstall) { *out = new(metav1.Duration) **out = **in } + if in.DeletionPropagation != nil { + in, out := &in.DeletionPropagation, &out.DeletionPropagation + *out = new(string) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Uninstall. diff --git a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml index cc552543f..15d3f8399 100644 --- a/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml +++ b/config/crd/bases/helm.toolkit.fluxcd.io_helmreleases.yaml @@ -1553,6 +1553,15 @@ spec: description: Uninstall holds the configuration for Helm uninstall actions for this HelmRelease. properties: + deletionPropagation: + default: background + description: DeletionPropagation specifies the deletion propagation + policy when a Helm uninstall is performed. + enum: + - background + - foreground + - orphan + type: string disableHooks: description: DisableHooks prevents hooks from running during the Helm rollback action. diff --git a/internal/action/uninstall.go b/internal/action/uninstall.go index 9c866e108..75fe6126d 100644 --- a/internal/action/uninstall.go +++ b/internal/action/uninstall.go @@ -50,6 +50,7 @@ func newUninstall(config *helmaction.Configuration, obj *v2.HelmRelease, opts [] uninstall.DisableHooks = obj.GetUninstall().DisableHooks uninstall.KeepHistory = obj.GetUninstall().KeepHistory uninstall.Wait = !obj.GetUninstall().DisableWait + uninstall.DeletionPropagation = obj.GetUninstall().GetDeletionPropagation() for _, opt := range opts { opt(uninstall)