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

[Bug]: Restore HCL language #155

Open
alexeagle opened this issue Feb 21, 2024 · 2 comments
Open

[Bug]: Restore HCL language #155

alexeagle opened this issue Feb 21, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@alexeagle
Copy link
Member

alexeagle commented Feb 21, 2024

What happened?

Switched from hcl to terraform because terraform-fmt doesn't cover everything

See comment:

# Note: terraform fmt cannot handle all HCL files such as .terraform.lock
# "Only .tf and .tfvars files can be processed with terraform fmt"
# so we define a custom language here instead of 'HCL' from github-linguist definition for the language.
# TODO: we should probably use https://terragrunt.gruntwork.io/docs/reference/cli-options/#hclfmt instead
# which does support the entire HCL language FWICT
'Terraform') patterns=('*.tf' '*.tfvars') ;;

@alexeagle alexeagle added the bug Something isn't working label Feb 21, 2024
@alexeagle
Copy link
Member Author

Some research:

I was wrong about https://terragrunt.gruntwork.io/docs/reference/cli-options/#hclfmt - it only wants to format "terragrunt" files, none of the HCL files in Silo were affected by it. Dead end.

The official HCL language does provide a formatter, however they don't ship any binary distribution.
https://github.com/hashicorp/hcl/blob/main/cmd/hclfmt/main.go

According to one of the HCL2 authors, each product that uses HCL actually ships its own fmt command intentionally because the domain-specifics may be formatted beyond what the language syntax understands:
hashicorp/vscode-hcl#98 (comment)

So that means users of rules_lint might expect their vault files to be vault fmt, packer files to be packer fmt, terraform to be terraform fmt, etc. This strikes me as a lot of burden for a little repo like this to take on.

Or, we can eschew these domain-specifics and just run the generic hclfmt, providing less value than those users expect, as they might take a file that's already "correctly formatted" according to rules_lint, run terraform fmt on it, and then be surprised that it makes modifications. In this case we'd also want to provide a precompiled binary to make things easier for users.

@alexeagle alexeagle added this to the 1.0 milestone Feb 22, 2024
@alexeagle alexeagle removed this from the 1.0 milestone Mar 27, 2024
@alexeagle
Copy link
Member Author

Slipping this from 1.0, it looks too underspecified

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant