From e6ab07144a7d0a827092c76e7e1f3a18c7b9b27a Mon Sep 17 00:00:00 2001 From: Imri Zvik Date: Wed, 27 Apr 2022 16:43:15 +0300 Subject: [PATCH] * Fixes 828 - If the update fails, don't persist the diff to the state. See https://github.com/hashicorp/terraform-plugin-sdk/issues/476 and https://www.terraform.io/plugin/sdkv2/guides/v2-upgrade-guide#removal-of-helper-schema-resourcedata-setpartial --- helm/resource_release.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/helm/resource_release.go b/helm/resource_release.go index 92c9a6eae2..7ce295e07e 100644 --- a/helm/resource_release.go +++ b/helm/resource_release.go @@ -596,32 +596,38 @@ func resourceReleaseUpdate(ctx context.Context, d *schema.ResourceData, meta int n := d.Get("namespace").(string) actionConfig, err := m.GetHelmConfiguration(n) if err != nil { + d.Partial(true) return diag.FromErr(err) } err = OCIRegistryLogin(actionConfig, d) if err != nil { + d.Partial(true) return diag.FromErr(err) } client := action.NewUpgrade(actionConfig) cpo, chartName, err := chartPathOptions(d, m, &client.ChartPathOptions) if err != nil { + d.Partial(true) return diag.FromErr(err) } c, path, err := getChart(d, m, chartName, cpo) if err != nil { + d.Partial(true) return diag.FromErr(err) } // check and update the chart's dependencies if needed updated, err := checkChartDependencies(d, c, path, m) if err != nil { + d.Partial(true) return diag.FromErr(err) } else if updated { // load the chart again if its dependencies have been updated c, err = loader.Load(path) if err != nil { + d.Partial(true) return diag.FromErr(err) } } @@ -649,6 +655,7 @@ func resourceReleaseUpdate(ctx context.Context, d *schema.ResourceData, meta int pr, err := postrender.NewExec(cmd) if err != nil { + d.Partial(true) return diag.FromErr(err) } @@ -657,12 +664,14 @@ func resourceReleaseUpdate(ctx context.Context, d *schema.ResourceData, meta int values, err := getValues(d) if err != nil { + d.Partial(true) return diag.FromErr(err) } name := d.Get("name").(string) r, err := client.Run(name, c, values) if err != nil { + d.Partial(true) return diag.FromErr(err) }