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

[Question] How to allow arbitrary user defined values #599

Open
manterfield opened this issue Mar 23, 2023 · 0 comments
Open

[Question] How to allow arbitrary user defined values #599

manterfield opened this issue Mar 23, 2023 · 0 comments

Comments

@manterfield
Copy link

I'm creating a DSL using HCL, and bumping up against the ability to let users define a (mostly) arbitrary attribute.

Given an example HCL config like so:

example "resource_putter" {
  inputs = {
    foo = "foostring"
    bar = true
    buzz = vars.some_complex_value
  }
}

The values of the keys under inputs can effectively be anything. I can happily parse this into cty.Values, but I've not a found a non-janky way of getting that into an interface{} as I would with unknown json input, for example.

The exact syntax above is one example. I can flex within reason if there's some more supported way of handling this built-in. I could have inputs as a block, or change the structure in other ways if it makes it more feasible.

My main needs are that users can define a structure without having to template json strings (will be error prone and bad user experience), they should have access to the expression context and the top level keys will always be strings.

I've been bashing my head against this for over a day now and I'm basically out of ideas beyond recursively parsing the structure myself. That will work, but it seems others must have faced and solved this ahead of me.

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

No branches or pull requests

1 participant