fix: Address "inconsistent result after apply" error by moving metadata recalc (#1713)
Some checks failed
build / Detect Go toolchain version (push) Has been cancelled
build / Parse version file (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
HashiCorp Copywrite / copywrite (push) Has been cancelled
tests / get_version_matrix (push) Has been cancelled
tests / unit_test (push) Has been cancelled
build / generate-metadata-file (push) Has been cancelled
build / upload-terraform-registry-manifest-artifact (push) Has been cancelled
build / Go darwin 386 build (push) Has been cancelled
build / Go freebsd 386 build (push) Has been cancelled
build / Go linux 386 build (push) Has been cancelled
build / Go windows 386 build (push) Has been cancelled
build / Go darwin amd64 build (push) Has been cancelled
build / Go freebsd amd64 build (push) Has been cancelled
build / Go linux amd64 build (push) Has been cancelled
build / Go windows amd64 build (push) Has been cancelled
build / Go freebsd arm build (push) Has been cancelled
build / Go linux arm build (push) Has been cancelled
build / Go darwin arm64 build (push) Has been cancelled
build / Go linux arm64 build (push) Has been cancelled
build / What's next? (push) Has been cancelled
tests / acc_test (push) Has been cancelled

* fix: Recompute metadata at the end of the diff function

* chore: Add changelog entry for PR #1713
This commit is contained in:
Marco Maurer (-Kilchhofer) 2025-11-06 17:29:39 +01:00 committed by GitHub
parent e199e5973d
commit b6a090b73c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 5 deletions

3
.changelog/1713.txt Normal file
View file

@ -0,0 +1,3 @@
```release-note:bug
`resource/helm_release`: Fix "inconsistent result after apply" error by moving recomputeMetadata function call
```

View file

@ -1971,11 +1971,6 @@ func (r *HelmRelease) ModifyPlan(ctx context.Context, req resource.ModifyPlanReq
// Always set desired state to DEPLOYED
plan.Status = types.StringValue(release.StatusDeployed.String())
if recomputeMetadata(plan, state) {
tflog.Debug(ctx, fmt.Sprintf("%s Metadata has changes, setting to unknown", logID))
plan.Metadata = types.ObjectUnknown(metadataAttrTypes())
}
if !useChartVersion(plan.Chart.ValueString(), plan.Repository.ValueString()) {
// Check if version has changed
if state != nil && !plan.Version.Equal(state.Version) {
@ -2275,6 +2270,11 @@ You should update the version in your configuration to %[2]q, or remove the vers
}
}
if recomputeMetadata(plan, state) {
tflog.Debug(ctx, fmt.Sprintf("%s Metadata has changes, setting to unknown", logID))
plan.Metadata = types.ObjectUnknown(metadataAttrTypes())
}
resp.Plan.Set(ctx, &plan)
}
@ -2291,6 +2291,9 @@ func recomputeMetadata(plan HelmReleaseModel, state *HelmReleaseModel) bool {
if !plan.Repository.Equal(state.Repository) {
return true
}
if !plan.Version.Equal(state.Version) {
return true
}
if !plan.Values.Equal(state.Values) {
return true
}