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

Does not support dev_overrides #84

Closed
skyzyx opened this issue Sep 8, 2023 · 2 comments
Closed

Does not support dev_overrides #84

skyzyx opened this issue Sep 8, 2023 · 2 comments

Comments

@skyzyx
Copy link

skyzyx commented Sep 8, 2023

$ hcledit version
0.2.9
$ cat ~/.terraformrc

provider_installation {
    dev_overrides {
        "mycompany/provider" = "/Users/me/go/bin/"
    }

    filesystem_mirror {
        path = "./terraform.d/plugins"
        include = ["mycompany.com/*/*"]
    }

    direct {
        exclude = ["mycompany.com/*/*"]
    }
}
$ cat ~/.terraformrc | hcledit block get dev_overrides
failed to parse input: -:3,9-10: Invalid argument name; Argument names must not be quoted.
$ cat ~/.terraformrc | hcledit block list
failed to parse input: -:3,9-10: Invalid argument name; Argument names must not be quoted.

However, the official docs say to quote the attribute name.

https://developer.hashicorp.com/terraform/cli/config/config-file#development-overrides-for-provider-developers

@minamijoyo
Copy link
Owner

Hi @skyzyx, Thank you for reporting the issue!

If I understand correctly, the syntax of .terraformrc is invalid as the HCL2 because an argument name ("mycompany/provider") must not be quoted, as shown in the error message.

The error comes from the HCL2 parser here:
https://github.com/hashicorp/hcl/blob/v2.17.0/hclsyntax/parser.go#L87

I was curious how Terraform parses the .terraformrc and found that the dev_overrides block was decoded as a map object using the low-level HCL1 API.
https://github.com/hashicorp/terraform/blob/v1.5.5/internal/command/cliconfig/provider_installation.go#L230-L244

The HCL1 is the legacy syntax used before Terraform v0.12 that allowed a block to be interpreted as a map depending on the application schema, which is not allowed in HCL2. I don't know why such a legacy one is still used after Terraform v0.12, but I assume it is due to some historical reason or technical constraint.

The hcledit supports only HCL2 and cannot parse invalid files as HCL2.

@skyzyx
Copy link
Author

skyzyx commented Sep 11, 2023

I didn't realize that Terraform core was falling back to HCL1 to parse this, as this is the current syntax published in the official docs.

Thank you for taking a look.

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

2 participants