From 8a5ccd70899b6c17f5e3947a1edf1d5084d28cd2 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sun, 26 Dec 2021 19:06:56 +0300 Subject: fix(depotfmt): handle multiple terraform files `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 Reviewed-by: grfn --- tools/depotfmt.nix | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/depotfmt.nix b/tools/depotfmt.nix index d1a1cb425a..c3c9852430 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" ] ''; -- cgit 1.4.1