Is there a way to list the current formatters appl...
# general
r
Is there a way to list the current formatters applied when running
pants fmt
? I'm trying to figure out why the terraform formatter does not seem to be running.
h
Good question. I don't think so, but just to verify - you have enabled the
pants.backend.experimental.terraform
backend in pants.toml?
And you've run
tailor
to generate appropriate BUILD file targets?
r
@happy-kitchen-89482 yep, here's my
pants.toml
Copy code
[GLOBAL]
pants_version = "2.15.0"
backend_packages = [
    "pants.backend.python",
    "pants.backend.experimental.java",
    "pants.backend.experimental.scala",
    "pants.backend.experimental.terraform"
]

[source]
marker_filenames = [ "setup.py" ]
root_patterns = [ "src", "terraform" ]

[jvm]
jdk = "termurin:1.17.0.6"

[scala.version_for_resolve]
jvm-default = "2.13.8"
And the terraform folder just has 2 files right now,
<http://main.tf|main.tf>
and
BUILD
- the build file has one line:
terraform_module()
Ooh, I partially figured it out. I forgot to add
::
on the end. Except now I'm hitting an exception:
Copy code
10:08:19.28 [ERROR] 1 Exception encountered:

Engine traceback:
  in `fmt` goal
  in Format with `terraform fmt`

Exception: Error hashing/capturing URL fetch response: Downloaded file was larger than expected digest
👍 1
Figured this out too, I think the file size in the default
known_versions
for terraform 1.0.7 must be wrong. I just added
1.4.0
and calculated the file size myself and it worked.
h
ah, evidently a bug in
known_versions
ooof
That is surprising though
Would you be able to submit a fix?
We generate those known_versions in the source using
build-support/bin/terraform_tool_versions.py
, so it's weird that there would be an error
r
Yep can do, but what's the purpose of having these SHAs and requiring the exact file size? Some kind of security measure?
h
Exactly
Maybe we just need to rerun build-support/bin/terraform_tool_versions.py and see if it produces a diff on that version, and why
r
Yeah very likely. I've also noticed there's no
init
,
plan
, or
apply
commands built in the terraform backend yet. The former is especially problematic because you can't actually run
validate
, which is called when running
pants check
, without running
init
first. IMO,
check
should run
init
,
validate
, and
plan
. It would also be super helpful to have
apply
available so I don't have to double download the terraform executable during CI/CD runs. Gonna open a handful of issues on Github and try to find some time this week to tackle them.
h
Great, @fast-nail-55400 and others will have feedback on those issues, particularly around how Pants caching would interact with something that changes external state, essentially a side-effect