Skip to content

Commit

Permalink
chore: use opentofu instead of terraform (#399)
Browse files Browse the repository at this point in the history
Avoids the unfree shenanigans
  • Loading branch information
zimbatm authored Aug 30, 2024
1 parent 8da3985 commit 2b9a5f9
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
14 changes: 7 additions & 7 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ func TestReadConfigFile(t *testing.T) {
as.Equal([]string{"*.sh"}, shfmt.Includes)
as.Nil(shfmt.Excludes)

// terraform
terraform, ok := cfg.Formatters["terraform"]
as.True(ok, "terraform formatter not found")
as.Equal("terraform", terraform.Command)
as.Equal([]string{"fmt"}, terraform.Options)
as.Equal([]string{"*.tf"}, terraform.Includes)
as.Nil(terraform.Excludes)
// opentofu
opentofu, ok := cfg.Formatters["opentofu"]
as.True(ok, "opentofu formatter not found")
as.Equal("tofu", opentofu.Command)
as.Equal([]string{"fmt"}, opentofu.Options)
as.Equal([]string{"*.tf"}, opentofu.Includes)
as.Nil(opentofu.Excludes)

// missing
foo, ok := cfg.Formatters["foo-fmt"]
Expand Down
7 changes: 1 addition & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@
};
};

outputs = inputs: let
inherit (inputs.nixpkgs) lib;
in
outputs = inputs:
inputs.blueprint {
inherit inputs;
prefix = "nix/";
nixpkgs.config = {
allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) ["terraform"];
};
};
}
2 changes: 1 addition & 1 deletion nix/packages/treefmt/formatters.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ with pkgs; [
shfmt
statix
deadnix
terraform
opentofu
dos2unix
yamlfmt
# util for unit testing
Expand Down
6 changes: 2 additions & 4 deletions test/examples/treefmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ options = ["-i", "2", "-s", "-w"]
includes = ["*.sh"]
priority = 2

[formatter.terraform]
# Careful, only terraform 1.3.0 or later accept a list of files.
# see https://github.com/numtide/treefmt/issues/97
command = "terraform"
[formatter.opentofu]
command = "tofu"
options = ["fmt"]
includes = ["*.tf"]

Expand Down

0 comments on commit 2b9a5f9

Please sign in to comment.