Skip to content

Commit 451aaa5

Browse files
author
Michael Rosenfeld
committed
fix: expand file extension patterns for tofu hooks
Update file matching patterns in .pre-commit-hooks.yaml to support .tofu, .tfvars, and other relevant extensions for OpenTofu workflows. Also clarify log message in tofu_wrapper_module_for_each.sh for missing files. Signed-off-by: Michael Rosenfeld <michael@rosesecurity.com>
1 parent ba56661 commit 451aaa5

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

.pre-commit-hooks.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
entry: hooks/infracost_breakdown.sh
55
language: script
66
require_serial: true
7-
files: \.((tf|tofu)(vars)?|hcl)$
7+
files: \.(tf|tofu|tfvars|hcl)$
88
exclude: \.terraform\/.*$
99

1010
- id: tofu_fmt
1111
name: OpenTofu fmt
1212
description: Rewrites all OpenTofu configuration files to a canonical format.
1313
entry: hooks/tofu_fmt.sh
1414
language: script
15-
files: \.(tf|tofu)(vars)?$
15+
files: \.(tf|tofu|tfvars|(tftest|tofutest|tfmock|tfquery)\.hcl)$
1616
exclude: \.terraform\/.*$
1717

1818
- id: tofu_docs
@@ -23,7 +23,7 @@
2323
require_serial: true
2424
entry: hooks/tofu_docs.sh
2525
language: script
26-
files: (\.(tf|tofu)|\.terraform\.lock\.hcl)$
26+
files: \.(tf|tofu|terraform\.lock\.hcl)$
2727
exclude: \.terraform\/.*$
2828

2929
- id: tofu_docs_without_aggregate_type_defaults
@@ -52,7 +52,7 @@
5252
require_serial: true
5353
entry: hooks/tofu_validate.sh
5454
language: script
55-
files: \.(tf|tofu)(vars)?$
55+
files: \.(tf|tofu|tfvars|terraform\.lock\.hcl)$
5656
exclude: \.terraform\/.*$
5757

5858
- id: tofu_providers_lock
@@ -70,7 +70,7 @@
7070
require_serial: true
7171
entry: hooks/tofu_tflint.sh
7272
language: script
73-
files: \.(tf|tofu)(vars)?$
73+
files: \.(tf|tofu|tfvars)$
7474
exclude: \.terraform\/.*$
7575

7676
- id: terragrunt_fmt
@@ -104,7 +104,7 @@
104104
Static analysis of OpenTofu templates to spot potential security issues.
105105
require_serial: true
106106
entry: hooks/tofu_tfsec.sh
107-
files: \.(tf|tofu)(vars)?$
107+
files: \.(tf|tofu|tfvars)$
108108
language: script
109109

110110
- id: tofu_trivy
@@ -113,7 +113,7 @@
113113
Static analysis of OpenTofu templates to spot potential security issues.
114114
require_serial: true
115115
entry: hooks/tofu_trivy.sh
116-
files: \.(tf|tofu)(vars)?$
116+
files: \.(tf|tofu|tfvars)$
117117
language: script
118118

119119
- id: checkov
@@ -123,7 +123,7 @@
123123
language: python
124124
pass_filenames: false
125125
always_run: false
126-
files: \.tf$
126+
files: \.(tf|tofu)$
127127
exclude: \.terraform\/.*$
128128
require_serial: true
129129

@@ -145,7 +145,7 @@
145145
pass_filenames: false
146146
always_run: false
147147
require_serial: true
148-
files: \.tf$
148+
files: \.(tf|tofu)$
149149
exclude: \.terraform\/.*$
150150

151151
- id: terrascan

hooks/tofu_wrapper_module_for_each.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ EOF
315315
all_tf_content=$(find "${full_module_dir}" -regex '.*\.(tf|tofu)' -maxdepth 1 -type f -exec cat {} +)
316316

317317
if [[ ! $all_tf_content ]]; then
318-
common::colorify "yellow" "Skipping ${full_module_dir} because there are no *.(tf|tofu) files."
318+
common::colorify "yellow" "Skipping ${full_module_dir} because there are no .tf or .tofu files."
319319
continue
320320
fi
321321

0 commit comments

Comments
 (0)