-
Notifications
You must be signed in to change notification settings - Fork 582
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
Read HCL file without evaluation. #585
Comments
Hi @normander, First, the reason for the error you received is probably due to having a Second, to answer your question on reading a file without evaluation - yes, you can decode your hcl config into Native Go values without evaluation. You can do so by utilizing type Data struct {
Name string `hcl:"name,label"`
Field1 hcl.Expression `hcl:"field1,attr"`
Remain hcl.Body `hcl:",remain"`
} When you decode your config, the resulting Note that a common approach when needing to leave certain fields unevaluated is to accomplish it in a stepped fashion. Start by defining a struct with "just enough" of the fields you absolutely need to decode into primitive go values, leave the rest as Here is a good answer to a similar question on decoding but not evaluating config until later... #496 (comment) |
@kamilpi did you get the answer you're looking for? |
Hello,
I want to read terraform/terragrunt configuration files, store them inside of my stricture in golang test and use them for any purpose like generating new files with a different configuration, and do the validation if this file suits the current version of tests.
Right now when I try to read the HCL file when there is something like a "merge" function(terraform) I receive an error like this:
Function calls not allowed; Functions may not be called here.
Is there any way to read the such file without evaluation?
The text was updated successfully, but these errors were encountered: