Skip to content

gohcl: Struct Embedding#667

Draft
cam72cam wants to merge 1 commit into
hashicorp:mainfrom
cam72cam:opentofu/gohcl-embedded-structs
Draft

gohcl: Struct Embedding#667
cam72cam wants to merge 1 commit into
hashicorp:mainfrom
cam72cam:opentofu/gohcl-embedded-structs

Conversation

@cam72cam

Copy link
Copy Markdown

A common pattern that does not currently work for decoding hcl is:

type Base struct {
    Field string `hcl:"my_field"`
}

type Variant struct {
    Base
    Value int `hcl:"my_value"`
}

This is fixed by making some recursive tweaks to schema.go and corresponding changes in decode and encode.

This code is functional for decode, but still requires encode changes as well as test coverage. I may end up refactoring this a bit as I fiddle with encode, but the core functionality is there.

Still needs encoder changes and tests
@hashicorp-cla

hashicorp-cla commented Mar 12, 2024

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants