Add ResourceBase fields to labeled block CTY values - #13
Open
victorfrederiknielsen wants to merge 1 commit into
Open
Add ResourceBase fields to labeled block CTY values#13victorfrederiknielsen wants to merge 1 commit into
victorfrederiknielsen wants to merge 1 commit into
Conversation
Enable labeled block references to be decoded into []types.ResourceBase by including meta, disabled, and depends_on fields in the CTY representation. Changes: - Add elementToCtyWithMeta function to include ResourceBase fields - Use gocty.ToCtyValue for clean meta generation instead of manual CTY - Add label field to CTY map via addLabelFieldToCtyMap helper - Add comprehensive tests for labeled block slice references - Consolidate test fixtures into valid.hcl for consistency
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.
Summary
Add meta, disabled, and depends_on fields to labeled block element CTY representations. This enables labeled block references (e.g.,
resource.aws_account.sandbox.user.admin) to be decoded into[]types.ResourceBasefields, completing the round-trip for HCL configurations that reference labeled blocks.Changes
Core CTY Conversion (
convert/convert.go)transformLabeledBlocksto build element reference pathselementToCtytoelementToCtyWithMetaand populate ResourceBase fields:meta.idwith the full reference path (e.g.,resource.aws_account.sandbox.user.admin)disabledasfalsedepends_onas empty listgocty.ToCtyValuefor clean meta struct conversion instead of manual CTY constructionaddLabelFieldToCtyMaphelper to include label field values in CTY outputTests
TestLabeledBlockCtyStructureto verify CTY includes meta/disabled/depends_on fieldsTestLabeledBlockReferenceSliceto test slice references likemembers = [resource...user.admin]TestLabeledBlockResourceBaseSliceto verify full round-trip with actual typesvalid.hclfor consistencyCloudTeamandCloudCredentialstest structsTest Fixtures
cloud_account.goName field tag tohcl:"name,label"for proper decodingcloud_team.gowith Members/Lead fields for slice reference testsTesting Strategy
TestLabeledBlock*)