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

terraform fmt should have the ability to ignore certain parts of the code #36208

Open
nbali opened this issue Dec 12, 2024 · 1 comment
Open
Labels
enhancement new new issue not yet triaged

Comments

@nbali
Copy link

nbali commented Dec 12, 2024

Terraform Version

latest

Use Cases

This is readable, and the differences are easily understandable by humans

  po_mapping            = [for p in values(var.projects) : { for o in concat(tolist( v.owners), ["serviceAccount:${var.provisioning_sa}"]) : "${p.project}:${o}" => { project : p.project,  owner : o } }]
  pe_mapping            = [for p in values(var.projects) : { for e in        tolist(v.editors)                                             : "${p.project}:${e}" => { project : p.project, editor : e } }]
  pv_mapping            = [for p in values(var.projects) : { for v in        tolist(v.viewers)                                             : "${p.project}:${v}" => { project : p.project, viewer : v } }]

The terraform formatted version decreased this readability.

Attempted Solutions

Ignoring the whole file is not an option, and couldn't find any solution that ignore only just a few lines

Proposal

  # fmt: off
  po_mapping            = [for p in values(var.projects) : { for o in concat(tolist( v.owners), ["serviceAccount:${var.provisioning_sa}"]) : "${p.project}:${o}" => { project : p.project,  owner : o } }]
  pe_mapping            = [for p in values(var.projects) : { for e in        tolist(v.editors)                                             : "${p.project}:${e}" => { project : p.project, editor : e } }]
  pv_mapping            = [for p in values(var.projects) : { for v in        tolist(v.viewers)                                             : "${p.project}:${v}" => { project : p.project, viewer : v } }]
  # fmt: on

References

No response

@nbali nbali added enhancement new new issue not yet triaged labels Dec 12, 2024
@crw
Copy link
Contributor

crw commented Dec 12, 2024

Thanks for this feature request! If you are viewing this issue and would like to indicate your interest, please use the 👍 reaction on the issue description to upvote this issue. We also welcome additional use case descriptions. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new new issue not yet triaged
Projects
None yet
Development

No branches or pull requests

2 participants