Skip to content

Commit ea85aee

Browse files
committed
chore: adding nix, update pre-commit
1 parent 7c9ba07 commit ea85aee

File tree

4 files changed

+68
-33
lines changed

4 files changed

+68
-33
lines changed

.gitignore

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,3 @@
1-
# Local .terraform directories
2-
**/.terraform/*
3-
4-
# .tfstate files
5-
*.tfstate
6-
*.tfstate.*
7-
8-
# Crash log files
9-
crash.log
10-
11-
# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
12-
# .tfvars files are managed as part of configuration and so should be included in
13-
# version control.
14-
#
15-
# example.tfvars
16-
17-
# Ignore override files as they are usually used to override resources locally and so
18-
# are not checked in
19-
override.tf
20-
override.tf.json
21-
*_override.tf
22-
*_override.tf.json
23-
24-
# Include override files you do wish to add to version control using negated pattern
25-
#
26-
# !example_override.tf
27-
28-
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
29-
# example: *tfplan*
30-
.terraform.*
31-
.terraform
1+
.terraform
2+
.terraform.lock.hcl
3+
terraform.tfstate*

.pre-commit-config.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v1.2.3
3+
rev: v5.0.0
44
hooks:
55
- id: trailing-whitespace
66
- repo: https://github.com/antonbabenko/pre-commit-terraform
7-
rev: v1.73.0
7+
rev: v1.98.1
88
hooks:
99
- id: terraform_fmt
1010
- id: terraform_validate
11+
- id: terraform_docs
12+
args:
13+
- --args=--config=.terraform-docs.yml

.terraform-docs.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
formatter: "markdown" # this is required
2+
3+
version: ""
4+
5+
recursive:
6+
enabled: false
7+
path: modules
8+
9+
content: ""
10+
11+
output:
12+
file: "README.md"
13+
mode: inject
14+
template: |-
15+
<!-- BEGIN_TF_DOCS -->
16+
{{ .Content }}
17+
<!-- END_TF_DOCS -->
18+
19+
sort:
20+
enabled: true
21+
by: name
22+
23+
sections:
24+
hide: # we remove the providers section because the actual provider used depends on the local build environment, we only document version constraints
25+
- providers

default.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{ pkgs ? import <nixpkgs> { }, system ? builtins.currentSystem }:
2+
3+
let
4+
# fake opentofu as terraform so that tools like terraform-docs pre-commit hook (which doesn't have tofu support)
5+
# fall back to tofu
6+
tofu_terraform =
7+
pkgs.stdenv.mkDerivation {
8+
name = "tofu-terraform";
9+
phases = [ "installPhase" ];
10+
installPhase = ''
11+
mkdir -p $out/bin
12+
echo '#!/usr/bin/env sh' > $out/bin/terraform
13+
echo 'tofu $@' > $out/bin/terraform
14+
chmod +x $out/bin/terraform
15+
'';
16+
};
17+
18+
in
19+
20+
pkgs.mkShell {
21+
NIX_SHELL = "terraform-meshplatform-modules";
22+
shellHook = ''
23+
echo starting terraform-meshplatform-modules shell
24+
'';
25+
26+
buildInputs = [
27+
pkgs.pre-commit
28+
pkgs.opentofu
29+
pkgs.tflint
30+
pkgs.terraform-docs
31+
32+
# fake tofu as terraform
33+
tofu_terraform
34+
];
35+
}

0 commit comments

Comments
 (0)