From 6047167fdb096cb072ac2b83c04781b8dc5eab0d Mon Sep 17 00:00:00 2001 From: Stano Bocinec Date: Tue, 17 Sep 2024 13:11:32 +0200 Subject: [PATCH] Enable "helm uninstall --ignore-not-found" equivalent behavior --- helm/resource_release.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/helm/resource_release.go b/helm/resource_release.go index 8b0299be7..b0a6f286c 100644 --- a/helm/resource_release.go +++ b/helm/resource_release.go @@ -57,6 +57,7 @@ var defaultAttributes = map[string]interface{}{ "create_namespace": false, "lint": false, "pass_credentials": false, + "ignore_not_found": false, } func resourceRelease() *schema.Resource { @@ -451,6 +452,12 @@ func resourceRelease() *schema.Resource { }, }, }, + "ignore_not_found": { + Type: schema.TypeBool, + Optional: true, + Default: defaultAttributes["ignore_not_found"], + Description: "If true, the provider will treat `release not found` as a successful uninstall during the resource destroy. Defaults to `false`.", + }, }, SchemaVersion: 1, StateUpgraders: []schema.StateUpgrader{ @@ -863,6 +870,7 @@ func resourceReleaseDelete(ctx context.Context, d *schema.ResourceData, meta int uninstall.Wait = d.Get("wait").(bool) uninstall.DisableHooks = d.Get("disable_webhooks").(bool) uninstall.Timeout = time.Duration(d.Get("timeout").(int)) * time.Second + uninstall.IgnoreNotFound = d.Get("ignore_not_found").(bool) res, err := uninstall.Run(name) if err != nil {