Skip to content

Commit

Permalink
* Fixes 828 - If the update fails, don't persist the diff to the stat…
Browse files Browse the repository at this point in the history
  • Loading branch information
imriz committed Apr 27, 2022
1 parent 8d63749 commit e6ab071
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions helm/resource_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down

0 comments on commit e6ab071

Please sign in to comment.