Closed alexjfisher closed 11 months ago
@tongueroo Hi! Is there anything else you'd like to see in this to get it over the line? Thanks.
Nope. Thanks for the detailed report. Wondering if should also just remove the noop option. Will consider either. Thanks.
My initial thought was when people are running it in CI they'll want to run with --noop
, but otherwise they'd want changes to be made.
But, now I've thought about it a bit more, if terraspace fmt
is fixing the .terraspace-cache
version then I don't suppose it serves any purpose. Have I understood that correctly?
So terraspace fmt demo
does a little trickery to achieve formatting the files in the desired app/stacks/demo
folder. It works on thr app
files directly instead of the .terraspace-cache
folder. There are some limits to it though, it will only consider a source file and format it if does not contain any ERB: https://github.com/boltops-tools/terraspace/blob/3d650171ce851ba0ebb0cef3a65112e97a7adcfb/lib/terraspace/cli/fmt/runner.rb#L28
Ah, ok. So the change is probably ok as is?
Thanks so much for the PR.
Decided to generalize it a bit more in the #332 These all work now
terraspace fmt demo -check
terraspace fmt demo -write=false -list
terraspace fmt -write=false -list
And also remove the unused --noop
and --verbose
options in #333 There's a noop in one small case, and just change it to an env var for now.
This is a 🙋♂️ feature or enhancement.
bundle exec rspec
to verify this)Summary
When the
--noop
option is used withterraspace fmt
, return non-zero if one or more files are needing to be formatted, (but leave the files untouched). Useful feature for CI/CD pipelines.Context
The
--noop
option seems to be common to all terraspace cli commands, but not implemented for all of them. Forfmt
we can use Terraform's-check
option.How to Test
Modify some stack/module tf files such that they have formatting issues. Run
terraspace fmt --noop
and note the return code and the fact files haven't been updated with the formatting fixes.Version Changes
Minor?