about summary refs log tree commit diff
path: root/tools
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2021-12-26T16·06+0300
committerclbot <clbot@tvl.fyi>2021-12-26T16·45+0000
commit8a5ccd70899b6c17f5e3947a1edf1d5084d28cd2 (patch)
treeec3359b3169ccf6b8995132c72c491dcd5b9923a /tools
parentc1d7714a212e80756e8f1b83cbc7f077dedb7abd (diff)
fix(depotfmt): handle multiple terraform files r/3424
`terraform fmt` can only handle a single path, but treefmt expects
formatters to be able to handle multiple paths at once.

this wraps it in a small shell script that calls `terraform fmt` with
at most one path at a time.

Change-Id: I2b9c1b89b5a276f3d4915b95608ce36b2509e334
Reviewed-on: https://cl.tvl.fyi/c/depot/+/4639
Tested-by: BuildkiteCI
Autosubmit: tazjin <mail@tazj.in>
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'tools')
-rw-r--r--tools/depotfmt.nix9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/depotfmt.nix b/tools/depotfmt.nix
index d1a1cb425ae3..c3c9852430af 100644
--- a/tools/depotfmt.nix
+++ b/tools/depotfmt.nix
@@ -3,6 +3,12 @@
 { depot, pkgs, ... }:
 
 let
+  # terraform fmt can't handle multiple paths at once, but treefmt
+  # expects this
+  terraformat = pkgs.writeShellScript "terraformat" ''
+    echo "$@" | xargs -n1 ${pkgs.terraform}/bin/terraform fmt
+  '';
+
   config = pkgs.writeText "depot-treefmt-config" ''
     [formatter.go]
     command = "${pkgs.go}/bin/gofmt"
@@ -10,8 +16,7 @@ let
     includes = ["*.go"]
 
     [formatter.tf]
-    command = "${pkgs.terraform}/bin/terraform"
-    options = [ "fmt" ]
+    command = "${terraformat}"
     includes = [ "*.tf" ]
   '';