Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for dynamic blocks when using ',remain' tag #469

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jlarfors
Copy link

Background:

We wanted a map[string]cty.Value from HCL. We tried using a map in cty but that means all the values should be of the same type, e.g. this fails:

fields = {
  my_bool = false
  my_string = "string"
}

So we resorted to using a block fields { ... } with the ,remain tag and the following go struct:

type DataFields struct {
	Values map[string]cty.Value `hcl:",remain"`
}

And now we can do:

fields {
  my_bool = true
  my_string = "string"
}

However this fails inside the dynamic block because the body.JustAttributes() method does not respect the scope/iteration inside a dynamic block. This small PR addresses this and would be great if you accept this PR.

@hashicorp-cla
Copy link

hashicorp-cla commented Jun 10, 2021

CLA assistant check
All committers have signed the CLA.

@jlarfors jlarfors changed the title Add support for dynamic blocks when using the ',remain' Add support for dynamic blocks when using ',remain' tag Jun 10, 2021
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.

None yet

2 participants