costmanagement: convert view resources to use typed models with Decode/Encode#32191
Open
costmanagement: convert view resources to use typed models with Decode/Encode#32191
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Community Note
Description
Convert
azurerm_subscription_cost_management_viewandazurerm_resource_group_cost_management_viewfrom returningnilinModelObject()with rawmetadata.ResourceData.Get()/Set()calls to using proper typed model structs withmetadata.Decode()/metadata.Encode().The
Update()methods preserve the existing read-modify-write pattern withHasChangeguards to ensurelifecycle { ignore_changes }continues to work correctly.This follows the same pattern applied to the consumption budget resources in #31929, the cost management export resources in #31930, and the scheduled action/anomaly alert resources in #31931.
PR Checklist
Changes to existing Resource / Data Source
Testing
go build ./internal/services/costmanagement/...— passesgo vet ./internal/services/costmanagement/...— passesmake static-analysis— passesgo test -short) — all cost management view tests discover and register withoutValidateModelObjectpanicsNo behavioral changes were made; existing acceptance tests cover the Create/Read/Update/Delete flows and will validate correctness when run with
TF_ACC.Change Log
azurerm_subscription_cost_management_view- refactor to use typed model with Decode/Encodeazurerm_resource_group_cost_management_view- refactor to use typed model with Decode/EncodeThis is a (please select all that apply):
Related Issue(s)
N/A — internal tech debt cleanup
AI Assistance Disclosure
AI was used for code generation of the typed model structs, expand/flatten helpers, and refactored CRUD methods. All changes were reviewed and validated manually.
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the provider.
Changes to Security Controls
No changes to security controls.