Compare commits

...

63 commits

Author SHA1 Message Date
Michael Rosenfeld
3f263a968c fix: typo fixes
Some checks failed
Release / Release (push) Has been cancelled
Signed-off-by: Michael Rosenfeld <michael@rosesecurity.com>
2026-05-27 09:25:16 +01:00
Nikolai Mishin
c9cd4a805d fix: Update hadolint installation
Signed-off-by: Nikolai Mishin <sanduku.default@gmail.com>
2026-05-26 23:00:40 +01:00
semantic-release-bot
ab333d78c6 chore(release): version 2.4.0 [skip ci]
# [2.4.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.3.0...v2.4.0) (2026-05-25)

### Bug Fixes

* expand file extension patterns for tofu hooks ([451aaa5](451aaa59b5))

### Features

* support .tofu file extension and update hooks/tools ([9624cc8](9624cc8f24))
2026-05-25 22:53:37 +00:00
kvendingoldo
fb62c63c56
Merge pull request #74 from RoseSecurity/support-tofu-file-extensions
feat: Support `.tofu` file extensions and pre-commit clean ups
2026-05-26 02:53:14 +04:00
Michael Rosenfeld
9624cc8f24
feat: support .tofu file extension and update hooks/tools
Add support for the `.tofu` file extension in OpenTofu config
matching and documentation. Update pre-commit hooks, regex, and
README to reflect support for `.tofu` files alongside `.tf` and
`.tfvars`. Fix minor shell quoting and array assignment issues.
Upgrade pre-commit-hooks to v6.0.0.

Signed-off-by: Michael Rosenfeld <michael@rosesecurity.com>
2026-05-24 22:06:26 -04:00
Michael Rosenfeld
451aaa59b5
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>
2026-05-24 22:06:26 -04:00
semantic-release-bot
ba56661031 chore(release): version 2.3.0 [skip ci]
# [2.3.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.2.2...v2.3.0) (2026-04-21)

### Features

* add terragrunt_validate_inputs hook ([0ca9eca](0ca9eca382))
2026-04-21 11:00:03 +00:00
kvendingoldo
10c515bc38
Merge pull request #72 from StorageMatt/feat/terragrunt-validate-inputs-hook
feat: Add terragrunt_validate_inputs hook
2026-04-21 14:59:35 +04:00
mketteringham
0ca9eca382 feat: add terragrunt_validate_inputs hook
Signed-off-by: mketteringham <mketteringham@williamhill.co.uk>
2026-04-21 11:42:58 +01:00
kvendingoldo
4adc698948
Merge pull request #66 from tofuutils/dependabot/github_actions/docker/login-action-4
gh-actions: bump docker/login-action from 3 to 4
2026-03-05 00:03:38 +04:00
dependabot[bot]
50351cae8e
gh-actions: bump docker/login-action from 3 to 4
Bumps [docker/login-action](https://github.com/docker/login-action) from 3 to 4.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v3...v4)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-04 11:07:57 +00:00
kvendingoldo
aaa2fd5580
Merge pull request #64 from tofuutils/dependabot/github_actions/tj-actions/changed-files-47.0.5
gh-actions: bump tj-actions/changed-files from 47.0.0 to 47.0.5
2026-03-03 23:46:06 +04:00
dependabot[bot]
4f6be1dd0d
gh-actions: bump tj-actions/changed-files from 47.0.0 to 47.0.5
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 47.0.0 to 47.0.5.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](24d32ffd49...22103cc46b)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: 47.0.5
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-03-03 11:06:54 +00:00
kvendingoldo
bf25ff2f46
Merge pull request #50 from tofuutils/dependabot/github_actions/cycjimmy/semantic-release-action-6.0.0
gh-actions: bump cycjimmy/semantic-release-action from 5.0.2 to 6.0.0
2025-11-18 17:20:43 +04:00
kvendingoldo
09452c660e
Merge pull request #51 from tofuutils/dependabot/github_actions/actions/checkout-5.0.1
gh-actions: bump actions/checkout from 5.0.0 to 5.0.1
2025-11-18 17:20:29 +04:00
dependabot[bot]
624daa51ed
gh-actions: bump actions/checkout from 5.0.0 to 5.0.1
Bumps [actions/checkout](https://github.com/actions/checkout) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v5...v5.0.1)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: 5.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-18 11:21:15 +00:00
dependabot[bot]
c3397c32d9
gh-actions: bump cycjimmy/semantic-release-action from 5.0.2 to 6.0.0
Bumps [cycjimmy/semantic-release-action](https://github.com/cycjimmy/semantic-release-action) from 5.0.2 to 6.0.0.
- [Release notes](https://github.com/cycjimmy/semantic-release-action/releases)
- [Changelog](https://github.com/cycjimmy/semantic-release-action/blob/main/docs/CHANGELOG.md)
- [Commits](ba330626c4...b12c8f6015)

---
updated-dependencies:
- dependency-name: cycjimmy/semantic-release-action
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-11-18 11:21:09 +00:00
semantic-release-bot
10864545dd chore(release): version 2.2.2 [skip ci]
## [2.2.2](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.2.1...v2.2.2) (2025-10-22)

### Bug Fixes

* replace deprecated hclfmt with hcl format command ([f1a589b](f1a589bd12))
2025-10-22 12:57:51 +00:00
kvendingoldo
a24fd775fb
Merge pull request #45 from widnyana/fix/hclfmt-deprecated
fix: Replace deprecated hclfmt with hcl format command
2025-10-22 16:57:10 +04:00
kvendingoldo
682111edbb
Merge pull request #48 from tofuutils/dependabot/github_actions/MaxymVlasov/dive-action-1.5.1
gh-actions: bump MaxymVlasov/dive-action from 1.5.0 to 1.5.1
2025-10-13 16:44:01 +04:00
dependabot[bot]
a3716be334
gh-actions: bump MaxymVlasov/dive-action from 1.5.0 to 1.5.1
Bumps [MaxymVlasov/dive-action](https://github.com/maxymvlasov/dive-action) from 1.5.0 to 1.5.1.
- [Release notes](https://github.com/maxymvlasov/dive-action/releases)
- [Commits](b08c8287e6...fafb796951)

---
updated-dependencies:
- dependency-name: MaxymVlasov/dive-action
  dependency-version: 1.5.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-13 12:21:03 +00:00
kvendingoldo
8ad84a44ef
Merge pull request #47 from tofuutils/dependabot/github_actions/cycjimmy/semantic-release-action-5.0.2
gh-actions: bump cycjimmy/semantic-release-action from 5.0.1 to 5.0.2
2025-10-10 19:10:36 +04:00
dependabot[bot]
430f50f0bd
gh-actions: bump cycjimmy/semantic-release-action from 5.0.1 to 5.0.2
Bumps [cycjimmy/semantic-release-action](https://github.com/cycjimmy/semantic-release-action) from 5.0.1 to 5.0.2.
- [Release notes](https://github.com/cycjimmy/semantic-release-action/releases)
- [Changelog](https://github.com/cycjimmy/semantic-release-action/blob/main/docs/CHANGELOG.md)
- [Commits](ebcbc66374...ba330626c4)

---
updated-dependencies:
- dependency-name: cycjimmy/semantic-release-action
  dependency-version: 5.0.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-10 11:22:34 +00:00
kvendingoldo
93e26a60e7
Merge pull request #46 from tofuutils/dependabot/github_actions/cycjimmy/semantic-release-action-5.0.1
gh-actions: bump cycjimmy/semantic-release-action from 5.0.0 to 5.0.1
2025-10-09 19:59:42 +04:00
dependabot[bot]
211d65d43d
gh-actions: bump cycjimmy/semantic-release-action from 5.0.0 to 5.0.1
Bumps [cycjimmy/semantic-release-action](https://github.com/cycjimmy/semantic-release-action) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/cycjimmy/semantic-release-action/releases)
- [Changelog](https://github.com/cycjimmy/semantic-release-action/blob/main/docs/CHANGELOG.md)
- [Commits](9cc899c47e...ebcbc66374)

---
updated-dependencies:
- dependency-name: cycjimmy/semantic-release-action
  dependency-version: 5.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-09 11:22:49 +00:00
widnyana
f1a589bd12
fix: replace deprecated hclfmt with hcl format command
Replace deprecated `terragrunt hclfmt` command with the recommended
`terragrunt hcl format` to eliminate deprecation warnings.

Resolves warning: "The `hclfmt` command is deprecated and will be
removed in a future version of Terragrunt."

Signed-off-by: widnyana <wid@widnyana.web.id>
2025-10-09 17:21:49 +07:00
kvendingoldo
16b5e9c289
Merge pull request #40 from tofuutils/dependabot/github_actions/cycjimmy/semantic-release-action-5.0.0
gh-actions: bump cycjimmy/semantic-release-action from 4.2.2 to 5.0.0
2025-10-02 14:38:22 +04:00
kvendingoldo
65db8f537f
Merge pull request #43 from tofuutils/dependabot/github_actions/tj-actions/changed-files-47.0.0
gh-actions: bump tj-actions/changed-files from 46.0.5 to 47.0.0
2025-09-15 20:58:34 +04:00
dependabot[bot]
f9d6074ab0
gh-actions: bump tj-actions/changed-files from 46.0.5 to 47.0.0
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 46.0.5 to 47.0.0.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](ed68ef82c0...24d32ffd49)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: 47.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-15 12:30:24 +00:00
kvendingoldo
701ddd21e1
Merge pull request #41 from tofuutils/dependabot/github_actions/actions/setup-python-6.0.0
gh-actions: bump actions/setup-python from 5.6.0 to 6.0.0
2025-09-04 22:51:34 +04:00
kvendingoldo
ecabde1843
Merge pull request #42 from tofuutils/dependabot/github_actions/actions/stale-10.0.0
gh-actions: bump actions/stale from 9.1.0 to 10.0.0
2025-09-04 22:51:28 +04:00
dependabot[bot]
f2b0eb603a
gh-actions: bump actions/stale from 9.1.0 to 10.0.0
Bumps [actions/stale](https://github.com/actions/stale) from 9.1.0 to 10.0.0.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](5bef64f19d...3a9db7e6a4)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: 10.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-04 14:02:40 +00:00
dependabot[bot]
84d857a5ae
gh-actions: bump actions/setup-python from 5.6.0 to 6.0.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.6.0 to 6.0.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](a26af69be9...e797f83bcb)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 6.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-04 13:18:51 +00:00
dependabot[bot]
a4ae94e826
gh-actions: bump cycjimmy/semantic-release-action from 4.2.2 to 5.0.0
Bumps [cycjimmy/semantic-release-action](https://github.com/cycjimmy/semantic-release-action) from 4.2.2 to 5.0.0.
- [Release notes](https://github.com/cycjimmy/semantic-release-action/releases)
- [Changelog](https://github.com/cycjimmy/semantic-release-action/blob/main/docs/CHANGELOG.md)
- [Commits](16ca923e6c...9cc899c47e)

---
updated-dependencies:
- dependency-name: cycjimmy/semantic-release-action
  dependency-version: 5.0.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-01 23:11:04 +00:00
kvendingoldo
d581d5f42f
Merge pull request #39 from tofuutils/dependabot/github_actions/amannn/action-semantic-pull-request-6.1.1
gh-actions: bump amannn/action-semantic-pull-request from 5.5.3 to 6.1.1
2025-08-23 13:42:59 +04:00
dependabot[bot]
f81b28692c
gh-actions: bump amannn/action-semantic-pull-request from 5.5.3 to 6.1.1
Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) from 5.5.3 to 6.1.1.
- [Release notes](https://github.com/amannn/action-semantic-pull-request/releases)
- [Changelog](https://github.com/amannn/action-semantic-pull-request/blob/main/CHANGELOG.md)
- [Commits](0723387faa...48f256284b)

---
updated-dependencies:
- dependency-name: amannn/action-semantic-pull-request
  dependency-version: 6.1.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-22 11:43:05 +00:00
kvendingoldo
4a08fa44c1
Merge pull request #35 from tofuutils/dependabot/github_actions/actions/checkout-5
gh-actions: bump actions/checkout from 4 to 5
2025-08-13 02:24:15 +04:00
dependabot[bot]
b2658a3f8e
gh-actions: bump actions/checkout from 4 to 5
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 5.
- [Release notes](https://github.com/actions/checkout/releases)
- [Commits](https://github.com/actions/checkout/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-08-12 17:26:54 +00:00
kvendingoldo
3357820262
Merge pull request #32 from telepath/patch-1
Update README.md
2025-07-12 03:39:29 +04:00
kvendingoldo
bac5ee6be0
Merge pull request #33 from tofuutils/dependabot/github_actions/cycjimmy/semantic-release-action-4.2.2
gh-actions: bump cycjimmy/semantic-release-action from 4.2.1 to 4.2.2
2025-07-08 17:45:49 +04:00
dependabot[bot]
977d08e2d1
gh-actions: bump cycjimmy/semantic-release-action from 4.2.1 to 4.2.2
Bumps [cycjimmy/semantic-release-action](https://github.com/cycjimmy/semantic-release-action) from 4.2.1 to 4.2.2.
- [Release notes](https://github.com/cycjimmy/semantic-release-action/releases)
- [Changelog](https://github.com/cycjimmy/semantic-release-action/blob/main/docs/CHANGELOG.md)
- [Commits](c4a2fa8906...16ca923e6c)

---
updated-dependencies:
- dependency-name: cycjimmy/semantic-release-action
  dependency-version: 4.2.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-07-07 14:24:37 +00:00
Benjamin Richter
d94583baf8
Update README.md
fix tofu_fmt heading
2025-06-18 12:24:20 +02:00
kvendingoldo
2bb866f953
Merge pull request #31 from tofuutils/dependabot/github_actions/cycjimmy/semantic-release-action-4.2.1
gh-actions: bump cycjimmy/semantic-release-action from 4.2.0 to 4.2.1
2025-06-09 20:46:17 +04:00
dependabot[bot]
407a900bbc
gh-actions: bump cycjimmy/semantic-release-action from 4.2.0 to 4.2.1
Bumps [cycjimmy/semantic-release-action](https://github.com/cycjimmy/semantic-release-action) from 4.2.0 to 4.2.1.
- [Release notes](https://github.com/cycjimmy/semantic-release-action/releases)
- [Changelog](https://github.com/cycjimmy/semantic-release-action/blob/main/docs/CHANGELOG.md)
- [Commits](0a51e81a6b...c4a2fa8906)

---
updated-dependencies:
- dependency-name: cycjimmy/semantic-release-action
  dependency-version: 4.2.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-09 12:28:37 +00:00
semantic-release-bot
04bfdda8eb chore(release): version 2.2.1 [skip ci]
## [2.2.1](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.2.0...v2.2.1) (2025-06-04)

### Bug Fixes

* make infracost_breakdown.sh compatible with bash 3.2 (macOS) ([df886fa](df886fa772))
* Update pre-commit/action version ([#30](https://github.com/tofuutils/pre-commit-opentofu/issues/30)) ([44c7b5d](44c7b5dec9))
2025-06-04 08:26:32 +00:00
df886fa772 fix: make infracost_breakdown.sh compatible with bash 3.2 (macOS)
- Replace mapfile with while-read loop for bash 3.2 compatibility
- Fix substring expressions to avoid negative indices:
  (${check: -1} => ${check:$((${#check}-1)):1})
- Replace negative array indexing with explicit length calculation
- Maintain identical functionality while supporting macOS default bash
  version

Signed-off-by: Oliver Ladner <waste@lugh.ch>
2025-06-04 10:26:05 +02:00
Nikolai Mishin
44c7b5dec9
fix: Update pre-commit/action version (#30)
This is needed to switch to the new cache:
https://gh.io/gha-cache-sunset

Signed-off-by: Nikolai Mishin <sanduku.default@gmail.com>
2025-06-04 00:11:35 +02:00
kvendingoldo
b73207253f
Merge pull request #26 from tofuutils/dependabot/github_actions/actions/stale-9.1.0
gh-actions: bump actions/stale from 9.0.0 to 9.1.0
2025-06-02 20:15:04 +04:00
kvendingoldo
f5f4fdf330
Merge pull request #27 from tofuutils/dependabot/github_actions/actions/setup-python-5.6.0
gh-actions: bump actions/setup-python from 5.0.0 to 5.6.0
2025-06-02 20:14:59 +04:00
kvendingoldo
5f888bddf6
Merge pull request #29 from tofuutils/dependabot/github_actions/tj-actions/changed-files-46
gh-actions: bump tj-actions/changed-files from 26.1 to 46
2025-06-02 20:14:53 +04:00
dependabot[bot]
98a556422a
gh-actions: bump tj-actions/changed-files from 26.1 to 46
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 26.1 to 46.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](58ae566dc6...ed68ef82c0)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: '46'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-02 12:20:13 +00:00
dependabot[bot]
ed9b22cc37
gh-actions: bump actions/setup-python from 5.0.0 to 5.6.0
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 5.0.0 to 5.6.0.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](0a5c615913...a26af69be9)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-version: 5.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-02 12:16:54 +00:00
dependabot[bot]
8604934d93
gh-actions: bump actions/stale from 9.0.0 to 9.1.0
Bumps [actions/stale](https://github.com/actions/stale) from 9.0.0 to 9.1.0.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](28ca103628...5bef64f19d)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-version: 9.1.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-02 12:10:49 +00:00
kvendingoldo
16722bff5a
Merge pull request #25 from tofuutils/dependabot/github_actions/amannn/action-semantic-pull-request-5.5.3
gh-actions: bump amannn/action-semantic-pull-request from 5.4.0 to 5.5.3
2025-06-02 01:29:49 +04:00
kvendingoldo
7eab6411d6
Merge pull request #24 from tofuutils/dependabot/github_actions/tj-actions/changed-files-26.1
gh-actions: bump tj-actions/changed-files from 13.1 to 26.1
2025-06-02 01:29:42 +04:00
kvendingoldo
da8319297d
Merge pull request #23 from tofuutils/dependabot/github_actions/MaxymVlasov/dive-action-1.5.0
gh-actions: bump MaxymVlasov/dive-action from 0.1.0 to 1.5.0
2025-06-02 01:29:33 +04:00
kvendingoldo
b27ad3a24a
Merge pull request #22 from tofuutils/dependabot/github_actions/cycjimmy/semantic-release-action-4.2.0
gh-actions: bump cycjimmy/semantic-release-action from 4.0.0 to 4.2.0
2025-06-02 01:29:25 +04:00
dependabot[bot]
df38ee3d39 gh-actions: bump pre-commit/action from 2.0.3 to 3.0.1
Bumps [pre-commit/action](https://github.com/pre-commit/action) from 2.0.3 to 3.0.1.
- [Release notes](https://github.com/pre-commit/action/releases)
- [Commits](9b88afc9cd...2c7b3805fd)

---
updated-dependencies:
- dependency-name: pre-commit/action
  dependency-version: 3.0.1
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-06-01 14:20:11 +02:00
dependabot[bot]
10393e2209
gh-actions: bump amannn/action-semantic-pull-request from 5.4.0 to 5.5.3
Bumps [amannn/action-semantic-pull-request](https://github.com/amannn/action-semantic-pull-request) from 5.4.0 to 5.5.3.
- [Release notes](https://github.com/amannn/action-semantic-pull-request/releases)
- [Changelog](https://github.com/amannn/action-semantic-pull-request/blob/main/CHANGELOG.md)
- [Commits](e9fabac35e...0723387faa)

---
updated-dependencies:
- dependency-name: amannn/action-semantic-pull-request
  dependency-version: 5.5.3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-31 23:54:13 +00:00
dependabot[bot]
700b083394
gh-actions: bump tj-actions/changed-files from 13.1 to 26.1
Bumps [tj-actions/changed-files](https://github.com/tj-actions/changed-files) from 13.1 to 26.1.
- [Release notes](https://github.com/tj-actions/changed-files/releases)
- [Changelog](https://github.com/tj-actions/changed-files/blob/main/HISTORY.md)
- [Commits](2c85495a7b...58ae566dc6)

---
updated-dependencies:
- dependency-name: tj-actions/changed-files
  dependency-version: '26.1'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-31 23:54:10 +00:00
dependabot[bot]
6be1b27016
gh-actions: bump MaxymVlasov/dive-action from 0.1.0 to 1.5.0
Bumps [MaxymVlasov/dive-action](https://github.com/maxymvlasov/dive-action) from 0.1.0 to 1.5.0.
- [Release notes](https://github.com/maxymvlasov/dive-action/releases)
- [Commits](0035999cae...b08c8287e6)

---
updated-dependencies:
- dependency-name: MaxymVlasov/dive-action
  dependency-version: 1.5.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-31 23:54:06 +00:00
dependabot[bot]
f8089e96a8
gh-actions: bump cycjimmy/semantic-release-action from 4.0.0 to 4.2.0
Bumps [cycjimmy/semantic-release-action](https://github.com/cycjimmy/semantic-release-action) from 4.0.0 to 4.2.0.
- [Release notes](https://github.com/cycjimmy/semantic-release-action/releases)
- [Changelog](https://github.com/cycjimmy/semantic-release-action/blob/main/docs/CHANGELOG.md)
- [Commits](61680d0e9b...0a51e81a6b)

---
updated-dependencies:
- dependency-name: cycjimmy/semantic-release-action
  dependency-version: 4.2.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-05-31 23:54:03 +00:00
Nikolai Mishin
0cbe561817
Create dependabot.yml 2025-06-01 01:53:20 +02:00
18 changed files with 333 additions and 47 deletions

10
.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,10 @@
---
version: 2
updates:
- package-ecosystem: "github-actions"
directory: /
schedule:
interval: daily
time: "11:00"
commit-message:
prefix: "gh-actions:"

View file

@ -9,13 +9,13 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with: with:
fetch-depth: 0 fetch-depth: 0
- name: Get changed Dockerfile - name: Get changed Dockerfile
id: changed-files-specific id: changed-files-specific
uses: tj-actions/changed-files@2c85495a7bb72f2734cb5181e29b2ee5e08e61f7 # v13.1 uses: tj-actions/changed-files@22103cc46bda19c2b464ffe86db46df6922fd323 # v47.0.5
with: with:
files: | files: |
Dockerfile Dockerfile
@ -52,7 +52,7 @@ jobs:
- name: Dive - check image for waste files - name: Dive - check image for waste files
if: steps.changed-files-specific.outputs.any_changed == 'true' if: steps.changed-files-specific.outputs.any_changed == 'true'
uses: MaxymVlasov/dive-action@0035999cae50d4ef657ac94be84f01812aa192a5 # v0.1.0 uses: MaxymVlasov/dive-action@fafb796951b322cc4926b8a5eafda89ab9de8edf # v1.5.1
with: with:
image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }}
config-file: ${{ github.workspace }}/.github/.dive-ci.yaml config-file: ${{ github.workspace }}/.github/.dive-ci.yaml

View file

@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v5.0.1
- name: Set up QEMU - name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v3
@ -22,7 +22,7 @@ jobs:
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io - name: Login to ghcr.io
uses: docker/login-action@v3 uses: docker/login-action@v4
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
@ -66,7 +66,7 @@ jobs:
"github_token=${{ secrets.GITHUB_TOKEN }}" "github_token=${{ secrets.GITHUB_TOKEN }}"
- name: Login to DockerHub Container Registry - name: Login to DockerHub Container Registry
uses: docker/login-action@v3 uses: docker/login-action@v4
with: with:
registry: registry.hub.docker.com registry: registry.hub.docker.com
username: ${{ secrets.DOCKERHUB_USER }} username: ${{ secrets.DOCKERHUB_USER }}
@ -98,4 +98,3 @@ jobs:
tags: | tags: |
registry.hub.docker.com/tofuutils/pre-commit-opentofu:nightly registry.hub.docker.com/tofuutils/pre-commit-opentofu:nightly
provenance: false provenance: false

View file

@ -14,7 +14,7 @@ jobs:
steps: steps:
# Please look up the latest version from # Please look up the latest version from
# https://github.com/amannn/action-semantic-pull-request/releases # https://github.com/amannn/action-semantic-pull-request/releases
- uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f # v5.4.0 - uses: amannn/action-semantic-pull-request@48f256284bd46cdaab1048c3721360e808335d50 # v6.1.1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:

View file

@ -6,7 +6,7 @@ jobs:
pre-commit: pre-commit:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
- run: | - run: |
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
@ -27,20 +27,24 @@ jobs:
sudo apt update && sudo apt install shellcheck sudo apt update && sudo apt install shellcheck
- name: Install hadolint - name: Install hadolint
env:
GH_TOKEN: ${{ github.token }}
run: | run: |
curl -L "$(curl -s https://api.github.com/repos/hadolint/hadolint/releases/latest | grep -o -E -m 1 "https://.+?/hadolint-Linux-x86_64")" > hadolint \ gh release download v2.14.0 --repo hadolint/hadolint --pattern "hadolint-linux-x86_64"
&& chmod +x hadolint && sudo mv hadolint /usr/bin/ mv hadolint-linux-x86_64 hadolint
chmod +x hadolint
sudo mv hadolint /usr/bin/
# Need to success pre-commit fix push # Need to success pre-commit fix push
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with: with:
fetch-depth: 0 fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }} ref: ${{ github.event.pull_request.head.sha }}
# Skip tofu_tflint which interferes to commit pre-commit auto-fixes # Skip tofu_tflint which interferes to commit pre-commit auto-fixes
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 - uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0
with: with:
python-version: '3.9' python-version: '3.9'
- name: Execute pre-commit - name: Execute pre-commit
uses: pre-commit/action@9b88afc9cd57fd75b655d5c71bd38146d07135fe # v2.0.3 uses: pre-commit/action@576ff52938d158a24ac7e009dfa94b1455e7df99
env: env:
SKIP: no-commit-to-branch,hadolint SKIP: no-commit-to-branch,hadolint
with: with:
@ -49,7 +53,7 @@ jobs:
# Run only skipped checks # Run only skipped checks
- name: Execute pre-commit check that have no auto-fixes - name: Execute pre-commit check that have no auto-fixes
if: always() if: always()
uses: pre-commit/action@9b88afc9cd57fd75b655d5c71bd38146d07135fe # v2.0.3 uses: pre-commit/action@576ff52938d158a24ac7e009dfa94b1455e7df99
env: env:
SKIP: check-added-large-files,check-merge-conflict,check-vcs-permalinks,forbid-new-submodules,no-commit-to-branch,end-of-file-fixer,trailing-whitespace,check-yaml,check-merge-conflict,check-executables-have-shebangs,check-case-conflict,mixed-line-ending,detect-aws-credentials,detect-private-key,shfmt,shellcheck SKIP: check-added-large-files,check-merge-conflict,check-vcs-permalinks,forbid-new-submodules,no-commit-to-branch,end-of-file-fixer,trailing-whitespace,check-yaml,check-merge-conflict,check-executables-have-shebangs,check-case-conflict,mixed-line-ending,detect-aws-credentials,detect-private-key,shfmt,shellcheck
with: with:

View file

@ -18,13 +18,13 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with: with:
persist-credentials: false persist-credentials: false
fetch-depth: 0 fetch-depth: 0
- name: Release - name: Release
uses: cycjimmy/semantic-release-action@61680d0e9b02ff86f5648ade99e01be17f0260a4 # v4.0.0 uses: cycjimmy/semantic-release-action@b12c8f6015dc215fe37bc154d4ad456dd3833c90 # v6.0.0
with: with:
semantic_version: 18.0.0 semantic_version: 18.0.0
extra_plugins: | extra_plugins: |

View file

@ -7,7 +7,7 @@ jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/stale@28ca1036281a5e5922ead5184a1bbf96e5fc984e # v9.0.0 - uses: actions/stale@3a9db7e6a41a89f618792c92c0e97cc736e1b13f # v10.0.0
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
# Staling issues and PR's # Staling issues and PR's

View file

@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0 rev: v6.0.0
hooks: hooks:
# Git style # Git style
- id: check-added-large-files - id: check-added-large-files

View file

@ -4,7 +4,7 @@
entry: hooks/infracost_breakdown.sh entry: hooks/infracost_breakdown.sh
language: script language: script
require_serial: true require_serial: true
files: \.((tf|tofu)(vars)?|hcl)$ files: \.(tf|tofu|tfvars|hcl)$
exclude: \.terraform\/.*$ exclude: \.terraform\/.*$
- id: tofu_fmt - id: tofu_fmt
@ -12,7 +12,7 @@
description: Rewrites all OpenTofu configuration files to a canonical format. description: Rewrites all OpenTofu configuration files to a canonical format.
entry: hooks/tofu_fmt.sh entry: hooks/tofu_fmt.sh
language: script language: script
files: \.(tf|tofu)(vars)?$ files: \.(tf|tofu|tfvars|(tftest|tofutest|tfmock|tfquery)\.hcl)$
exclude: \.terraform\/.*$ exclude: \.terraform\/.*$
- id: tofu_docs - id: tofu_docs
@ -23,7 +23,7 @@
require_serial: true require_serial: true
entry: hooks/tofu_docs.sh entry: hooks/tofu_docs.sh
language: script language: script
files: (\.(tf|tofu)|\.terraform\.lock\.hcl)$ files: \.(tf|tofu|terraform\.lock\.hcl)$
exclude: \.terraform\/.*$ exclude: \.terraform\/.*$
- id: tofu_docs_without_aggregate_type_defaults - id: tofu_docs_without_aggregate_type_defaults
@ -52,7 +52,7 @@
require_serial: true require_serial: true
entry: hooks/tofu_validate.sh entry: hooks/tofu_validate.sh
language: script language: script
files: \.(tf|tofu)(vars)?$ files: \.(tf|tofu|tfvars|terraform\.lock\.hcl)$
exclude: \.terraform\/.*$ exclude: \.terraform\/.*$
- id: tofu_providers_lock - id: tofu_providers_lock
@ -70,7 +70,7 @@
require_serial: true require_serial: true
entry: hooks/tofu_tflint.sh entry: hooks/tofu_tflint.sh
language: script language: script
files: \.(tf|tofu)(vars)?$ files: \.(tf|tofu|tfvars)$
exclude: \.terraform\/.*$ exclude: \.terraform\/.*$
- id: terragrunt_fmt - id: terragrunt_fmt
@ -90,13 +90,21 @@
files: (\.hcl)$ files: (\.hcl)$
exclude: \.terraform\/.*$ exclude: \.terraform\/.*$
- id: terragrunt_validate_inputs
name: Terragrunt validate inputs
description: Validates Terragrunt unused and undefined inputs.
entry: hooks/terragrunt_validate_inputs.sh
language: script
files: (\.hcl)$
exclude: \.terraform\/.*$
- id: tofu_tfsec - id: tofu_tfsec
name: OpenTofu validate with tfsec (deprecated, use "tofu_trivy") name: OpenTofu validate with tfsec (deprecated, use "tofu_trivy")
description: description:
Static analysis of OpenTofu templates to spot potential security issues. Static analysis of OpenTofu templates to spot potential security issues.
require_serial: true require_serial: true
entry: hooks/tofu_tfsec.sh entry: hooks/tofu_tfsec.sh
files: \.(tf|tofu)(vars)?$ files: \.(tf|tofu|tfvars)$
language: script language: script
- id: tofu_trivy - id: tofu_trivy
@ -105,7 +113,7 @@
Static analysis of OpenTofu templates to spot potential security issues. Static analysis of OpenTofu templates to spot potential security issues.
require_serial: true require_serial: true
entry: hooks/tofu_trivy.sh entry: hooks/tofu_trivy.sh
files: \.(tf|tofu)(vars)?$ files: \.(tf|tofu|tfvars)$
language: script language: script
- id: checkov - id: checkov
@ -115,7 +123,7 @@
language: python language: python
pass_filenames: false pass_filenames: false
always_run: false always_run: false
files: \.tf$ files: \.(tf|tofu)$
exclude: \.terraform\/.*$ exclude: \.terraform\/.*$
require_serial: true require_serial: true
@ -137,7 +145,7 @@
pass_filenames: false pass_filenames: false
always_run: false always_run: false
require_serial: true require_serial: true
files: \.tf$ files: \.(tf|tofu)$
exclude: \.terraform\/.*$ exclude: \.terraform\/.*$
- id: terrascan - id: terrascan

View file

@ -2,6 +2,40 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
# [2.4.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.3.0...v2.4.0) (2026-05-25)
### Bug Fixes
* expand file extension patterns for tofu hooks ([451aaa5](https://github.com/tofuutils/pre-commit-opentofu/commit/451aaa59b552eb3913629c835af8b6b568aab120))
### Features
* support .tofu file extension and update hooks/tools ([9624cc8](https://github.com/tofuutils/pre-commit-opentofu/commit/9624cc8f24177378449203194b4f0ee71bc6c1a0))
# [2.3.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.2.2...v2.3.0) (2026-04-21)
### Features
* add terragrunt_validate_inputs hook ([0ca9eca](https://github.com/tofuutils/pre-commit-opentofu/commit/0ca9eca3823420f31d09c62bf1672bea03ca3e07))
## [2.2.2](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.2.1...v2.2.2) (2025-10-22)
### Bug Fixes
* replace deprecated hclfmt with hcl format command ([f1a589b](https://github.com/tofuutils/pre-commit-opentofu/commit/f1a589bd124b277cc02fcbf04ee05017fb8822c0))
## [2.2.1](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.2.0...v2.2.1) (2025-06-04)
### Bug Fixes
* make infracost_breakdown.sh compatible with bash 3.2 (macOS) ([df886fa](https://github.com/tofuutils/pre-commit-opentofu/commit/df886fa772e7d1eedf5603327c0cf02968e7d779))
* Update pre-commit/action version ([#30](https://github.com/tofuutils/pre-commit-opentofu/issues/30)) ([44c7b5d](https://github.com/tofuutils/pre-commit-opentofu/commit/44c7b5dec9362d2fe7ed5e8786f4d95956791d3d))
# [2.2.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.1.0...v2.2.0) (2025-03-29) # [2.2.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.1.0...v2.2.0) (2025-03-29)
@ -14,7 +48,7 @@ All notable changes to this project will be documented in this file.
### Features ### Features
* spport .tofu files ([#6](https://github.com/tofuutils/pre-commit-opentofu/issues/6)) ([e059c58](https://github.com/tofuutils/pre-commit-opentofu/commit/e059c5859bceddf1ca018f55851f6940ad51f1c2)) * support .tofu files ([#6](https://github.com/tofuutils/pre-commit-opentofu/issues/6)) ([e059c58](https://github.com/tofuutils/pre-commit-opentofu/commit/e059c5859bceddf1ca018f55851f6940ad51f1c2))
# [2.0.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v1.0.4...v2.0.0) (2024-09-25) # [2.0.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v1.0.4...v2.0.0) (2024-09-25)

View file

@ -22,7 +22,7 @@ RUN [ ${PRE_COMMIT_VERSION} = "latest" ] && pip3 install --no-cache-dir pre-comm
RUN curl -LO https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip \ RUN curl -LO https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip \
&& curl -LO https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_SHA256SUMS \ && curl -LO https://github.com/opentofu/opentofu/releases/download/v${TOFU_VERSION}/tofu_${TOFU_VERSION}_SHA256SUMS \
&& [ $(sha256sum "tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip" | cut -f 1 -d ' ') = "$(grep "tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip" tofu_*_SHA256SUMS | cut -f 1 -d ' ')" ] \ && [ "$(sha256sum "tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip" | cut -f 1 -d ' ')" = "$(grep "tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip" tofu_*_SHA256SUMS | cut -f 1 -d ' ')" ] \
&& unzip tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip -d /usr/bin/ \ && unzip tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip -d /usr/bin/ \
&& rm "tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip" \ && rm "tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip" \
&& rm "tofu_${TOFU_VERSION}_SHA256SUMS" && rm "tofu_${TOFU_VERSION}_SHA256SUMS"
@ -235,4 +235,3 @@ ENV INFRACOST_API_KEY=${INFRACOST_API_KEY:-}
ENV INFRACOST_SKIP_UPDATE_CHECK=${INFRACOST_SKIP_UPDATE_CHECK:-false} ENV INFRACOST_SKIP_UPDATE_CHECK=${INFRACOST_SKIP_UPDATE_CHECK:-false}
ENTRYPOINT [ "/entrypoint.sh" ] ENTRYPOINT [ "/entrypoint.sh" ]

View file

@ -60,7 +60,7 @@ If you are using `pre-commit-opentofu` already or want to support its developmen
</sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub><br><br> </sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub><br><br>
* [`checkov`](https://github.com/bridgecrewio/checkov) required for `tofu_checkov` hook. * [`checkov`](https://github.com/bridgecrewio/checkov) required for `tofu_checkov` hook.
* [`terraform-docs`](https://github.com/terraform-docs/terraform-docs) required for `tofu_docs` hook. * [`terraform-docs`](https://github.com/terraform-docs/terraform-docs) required for `tofu_docs` hook.
* [`terragrunt`](https://terragrunt.gruntwork.io/docs/getting-started/install/) required for `terragrunt_validate` hook. * [`terragrunt`](https://terragrunt.gruntwork.io/docs/getting-started/install/) required for `terragrunt_validate` and `terragrunt_validate_inputs` hooks.
* [`terrascan`](https://github.com/tenable/terrascan) required for `terrascan` hook. * [`terrascan`](https://github.com/tenable/terrascan) required for `terrascan` hook.
* [`TFLint`](https://github.com/terraform-linters/tflint) required for `tofu_tflint` hook. * [`TFLint`](https://github.com/terraform-linters/tflint) required for `tofu_tflint` hook.
* [`TFSec`](https://github.com/liamg/tfsec) required for `tofu_tfsec` hook. * [`TFSec`](https://github.com/liamg/tfsec) required for `tofu_tfsec` hook.
@ -266,9 +266,35 @@ TAG=latest
docker run --rm --entrypoint cat tofuutils/pre-commit-opentofu:$TAG /usr/bin/tools_versions_info docker run --rm --entrypoint cat tofuutils/pre-commit-opentofu:$TAG /usr/bin/tools_versions_info
``` ```
### Example: Terragrunt Input Validation
Use `terragrunt_validate_inputs` to check that Terragrunt inputs line up with the module variables they are passed into:
```yaml
repos:
- repo: https://github.com/tofuutils/pre-commit-opentofu
rev: <VERSION> # Get the latest from: https://github.com/tofuutils/pre-commit-opentofu/releases
hooks:
- id: terragrunt_fmt
- id: terragrunt_validate_inputs
args:
- --args=--terragrunt-strict-validate
```
> **Note**: This hook automatically uses `terragrunt validate-inputs` for older Terragrunt releases and `terragrunt hcl validate --inputs` for newer releases.
>
> If Terragrunt reports intermittent `.terragrunt-cache` download or `file exists` errors in your repository, run this hook serially in your consumer configuration:
>
> ```yaml
> - id: terragrunt_validate_inputs
> require_serial: true
> args:
> - --args=--terragrunt-strict-validate
> ```
## Available Hooks ## Available Hooks
There are several [pre-commit](https://pre-commit.com/) hooks to keep OpenTofu configurations (both `*.tf` and `*.tfvars`) and Terragrunt configurations (`*.hcl`) in a good shape: There are several [pre-commit](https://pre-commit.com/) hooks to keep OpenTofu configurations (`*.tf`, `*.tofu`, and `*.tfvars`) and Terragrunt configurations (`*.hcl`) in a good shape:
<!-- markdownlint-disable no-inline-html --> <!-- markdownlint-disable no-inline-html -->
| Hook name | Description | Dependencies<br><sup>[Install instructions here](#1-install-dependencies)</sup> | | Hook name | Description | Dependencies<br><sup>[Install instructions here](#1-install-dependencies)</sup> |
@ -286,6 +312,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep OpenTofu c
| `tofu_validate` | Validates all Terraform configuration files. [Hook notes](#tofu_validate) | `jq`, only for `--retry-once-with-cleanup` flag | | `tofu_validate` | Validates all Terraform configuration files. [Hook notes](#tofu_validate) | `jq`, only for `--retry-once-with-cleanup` flag |
| `terragrunt_fmt` | Reformat all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) to a canonical format. | `terragrunt` | | `terragrunt_fmt` | Reformat all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) to a canonical format. | `terragrunt` |
| `terragrunt_validate` | Validates all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) | `terragrunt` | | `terragrunt_validate` | Validates all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) | `terragrunt` |
| `terragrunt_validate_inputs` | Validates Terragrunt unused and undefined inputs. | `terragrunt` |
| `tofu_wrapper_module_for_each` | Generates OpenTofu wrappers with `for_each` in module. [Hook notes](#terraform_wrapper_module_for_each) | `hcledit` | | `tofu_wrapper_module_for_each` | Generates OpenTofu wrappers with `for_each` in module. [Hook notes](#terraform_wrapper_module_for_each) | `hcledit` |
| `terrascan` | [terrascan](https://github.com/tenable/terrascan) Detect compliance and security violations. [Hook notes](#terrascan) | `terrascan` | | `terrascan` | [terrascan](https://github.com/tenable/terrascan) Detect compliance and security violations. [Hook notes](#terrascan) | `terrascan` |
| `tfupdate` | [tfupdate](https://github.com/minamijoyo/tfupdate) Update version constraints of OpenTofu core, providers, and modules. [Hook notes](#tfupdate) | `tfupdate` | | `tfupdate` | [tfupdate](https://github.com/minamijoyo/tfupdate) Update version constraints of OpenTofu core, providers, and modules. [Hook notes](#tfupdate) | `tfupdate` |
@ -299,6 +326,8 @@ Check the [source file](https://github.com/tofuutils/pre-commit-opentofu/blob/ma
OpenTofu operates on a per-dir basis, while `pre-commit` framework only supports files and files that exist. This means if you only remove the TF-related file without any other changes in the same dir, checks will be skipped. Example and details [here](https://github.com/pre-commit/pre-commit/issues/3048). OpenTofu operates on a per-dir basis, while `pre-commit` framework only supports files and files that exist. This means if you only remove the TF-related file without any other changes in the same dir, checks will be skipped. Example and details [here](https://github.com/pre-commit/pre-commit/issues/3048).
Hooks match `*.tofu` files where OpenTofu configuration files are supported, but some wrapped third-party tools may lag behind OpenTofu's native `*.tofu` parsing. If a hook runs `terraform-docs`, `tflint`, `tfsec`, `trivy`, `checkov`, `infracost`, or `tfupdate`, make sure the installed tool version supports the file extensions used in your repository.
### All hooks: Usage of environment variables in `--args` ### All hooks: Usage of environment variables in `--args`
> All, except deprecated hooks: `checkov`, `tofu_docs_replace` > All, except deprecated hooks: `checkov`, `tofu_docs_replace`
@ -552,7 +581,7 @@ To replicate functionality in `tofu_docs` hook:
- --args=--config=.terraform-docs.yml - --args=--config=.terraform-docs.yml
``` ```
### terraftofu_fmtorm_fmt ### tofu_fmt
1. `tofu_fmt` supports custom arguments so you can pass [supported flags](https://www.terraform.io/docs/cli/commands/fmt.html#usage). Eg: 1. `tofu_fmt` supports custom arguments so you can pass [supported flags](https://www.terraform.io/docs/cli/commands/fmt.html#usage). Eg:
@ -689,7 +718,7 @@ To replicate functionality in `tofu_docs` hook:
- --args=--config=__GIT_WORKING_DIR__/.tflint.hcl - --args=--config=__GIT_WORKING_DIR__/.tflint.hcl
``` ```
3. By default, pre-commit-opentofu performs directory switching into the OpenTofu modules for you. If you want to delgate the directory changing to the binary - this will allow tflint to determine the full paths for error/warning messages, rather than just module relative paths. *Note: this requires `tflint>=0.44.0`.* For example: 3. By default, pre-commit-opentofu performs directory switching into the OpenTofu modules for you. If you want to delegate the directory changing to the binary - this will allow tflint to determine the full paths for error/warning messages, rather than just module relative paths. *Note: this requires `tflint>=0.44.0`.* For example:
```yaml ```yaml
- id: tofu_tflint - id: tofu_tflint
@ -903,7 +932,7 @@ To replicate functionality in `tofu_docs` hook:
require_serial: true require_serial: true
entry: .generate-providers.sh entry: .generate-providers.sh
language: script language: script
files: \.tf(vars)?$ files: \.(tf|tofu|tfvars)$
pass_filenames: false pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks

View file

@ -112,7 +112,7 @@ function common::parse_and_export_env_vars {
while true; do while true; do
# Check if at least 1 env var exists in `$arg` # Check if at least 1 env var exists in `$arg`
# shellcheck disable=SC2016 # '${' should not be expanded # shellcheck disable=SC2016 # '${' should not be expanded
if [[ "$arg" =~ .*'${'[A-Z_][A-Z0-9_]+?'}'.* ]]; then if [[ "$arg" =~ .*'${'[A-Z_][A-Z0-9_]*'}'.* ]]; then
# Get `ENV_VAR` from `.*${ENV_VAR}.*` # Get `ENV_VAR` from `.*${ENV_VAR}.*`
local env_var_name=${arg#*$\{} local env_var_name=${arg#*$\{}
env_var_name=${env_var_name%%\}*} env_var_name=${env_var_name%%\}*}
@ -123,7 +123,7 @@ function common::parse_and_export_env_vars {
# `$arg` will be checked in `if` conditional, `$ARGS` will be used in the next functions. # `$arg` will be checked in `if` conditional, `$ARGS` will be used in the next functions.
# shellcheck disable=SC2016 # '${' should not be expanded # shellcheck disable=SC2016 # '${' should not be expanded
arg=${arg/'${'$env_var_name'}'/$env_var_value} arg=${arg/'${'$env_var_name'}'/$env_var_value}
ARGS[$arg_idx]=$arg ARGS[arg_idx]=$arg
# shellcheck disable=SC2016 # '${' should not be expanded # shellcheck disable=SC2016 # '${' should not be expanded
common::colorify "green" 'After ${'"$env_var_name"'} expansion: '"'$arg'\n" common::colorify "green" 'After ${'"$env_var_name"'} expansion: '"'$arg'\n"
continue continue

View file

@ -70,19 +70,24 @@ function infracost_breakdown_ {
# -h .totalHourlyCost > 0.1 # -h .totalHourlyCost > 0.1
# --hook-config=.currency == "USD" # --hook-config=.currency == "USD"
first_char=${check:0:1} first_char=${check:0:1}
last_char=${check: -1} last_char=${check:$((${#check} - 1)):1}
if [ "$first_char" == "$last_char" ] && { if [ "$first_char" == "$last_char" ] && {
[ "$first_char" == '"' ] || [ "$first_char" == "'" ] [ "$first_char" == '"' ] || [ "$first_char" == "'" ]
}; then }; then
check="${check:1:-1}" check="${check:1:$((${#check} - 2))}"
fi fi
mapfile -t operations < <(echo "$check" | grep -oE '[!<>=]{1,2}') # Replace mapfile with while read loop for bash 3.2 compatibility
operations=()
while IFS= read -r line; do
operations+=("$line")
done < <(echo "$check" | grep -oE '[!<>=]{1,2}')
# Get the very last operator, that is used in comparison inside `jq` query. # Get the very last operator, that is used in comparison inside `jq` query.
# From the example below we need to pick the `>` which is in between `add` and `1000`, # From the example below we need to pick the `>` which is in between `add` and `1000`,
# but not the `!=`, which goes earlier in the `jq` expression # but not the `!=`, which goes earlier in the `jq` expression
# [.projects[].diff.totalMonthlyCost | select (.!=null) | tonumber] | add > 1000 # [.projects[].diff.totalMonthlyCost | select (.!=null) | tonumber] | add > 1000
operation=${operations[-1]} operation=${operations[$((${#operations[@]} - 1))]}
IFS="$operation" read -r -a jq_check <<< "$check" IFS="$operation" read -r -a jq_check <<< "$check"
real_value="$(jq "${jq_check[0]}" <<< "$RESULTS")" real_value="$(jq "${jq_check[0]}" <<< "$RESULTS")"

View file

@ -12,7 +12,7 @@ function main {
common::parse_cmdline "$@" common::parse_cmdline "$@"
common::export_provided_env_vars "${ENV_VARS[@]}" common::export_provided_env_vars "${ENV_VARS[@]}"
common::parse_and_export_env_vars common::parse_and_export_env_vars
# JFYI: terragrunt hclfmt color already suppressed via PRE_COMMIT_COLOR=never # JFYI: terragrunt hcl format color already suppressed via PRE_COMMIT_COLOR=never
# shellcheck disable=SC2153 # False positive # shellcheck disable=SC2153 # False positive
common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}"
@ -40,7 +40,7 @@ function per_dir_hook_unique_part {
local -a -r args=("$@") local -a -r args=("$@")
# pass the arguments to hook # pass the arguments to hook
terragrunt hclfmt "${args[@]}" terragrunt hcl format "${args[@]}"
# return exit code to common::per_dir_hook # return exit code to common::per_dir_hook
local exit_code=$? local exit_code=$?
@ -57,7 +57,7 @@ function run_hook_on_whole_repo {
local -a -r args=("$@") local -a -r args=("$@")
# pass the arguments to hook # pass the arguments to hook
terragrunt hclfmt "$(pwd)" "${args[@]}" terragrunt hcl format "$(pwd)" "${args[@]}"
# return exit code to common::per_dir_hook # return exit code to common::per_dir_hook
local exit_code=$? local exit_code=$?

View file

@ -0,0 +1,198 @@
#!/usr/bin/env bash
set -eo pipefail
# globals variables
# shellcheck disable=SC2155 # No way to assign to readonly variable in separate lines
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
# shellcheck source=_common.sh
. "$SCRIPT_DIR/_common.sh"
function main {
common::initialize "$SCRIPT_DIR"
common::parse_cmdline "$@"
common::export_provided_env_vars "${ENV_VARS[@]}"
common::parse_and_export_env_vars
# JFYI: terragrunt validate color already suppressed via PRE_COMMIT_COLOR=never
if terragrunt_version_ge_0_78; then
normalize_validate_args_for_modern_terragrunt
readonly SUBCOMMAND=("hcl" "validate" "--inputs")
readonly RUN_ALL_SUBCOMMAND=("run" "--all" "hcl" "validate" "--inputs")
# shellcheck disable=SC2153 # False positive
common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}"
return
fi
run_legacy_validate_inputs
}
function normalize_validate_args_for_modern_terragrunt {
local arg_idx
for arg_idx in "${!ARGS[@]}"; do
case "${ARGS[$arg_idx]}" in
--terragrunt-strict-validate | --strict-validate)
ARGS[arg_idx]="--strict"
;;
esac
done
}
function terragrunt_version_ge_0_78 {
local version_raw
local version
local major
local minor
version_raw=$(terragrunt --version 2> /dev/null || true)
version=$(echo "$version_raw" | sed -E 's/.*v?([0-9]+)\.([0-9]+)\.([0-9]+).*/\1.\2.\3/')
if [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
return 1
fi
IFS=. read -r major minor _ <<< "$version"
if ((major > 0)); then
return 0
fi
if ((minor >= 78)); then
return 0
fi
return 1
}
function run_legacy_validate_inputs {
local -a unit_dirs=()
local final_exit_code=0
local dir_path
while read -r dir_path; do
if [[ -n $dir_path ]]; then
unit_dirs+=("$dir_path")
fi
done < <(legacy_unit_dirs_from_files)
if [[ ${#unit_dirs[@]} -eq 0 ]]; then
return 0
fi
# preserve errexit status
shopt -qo errexit && ERREXIT_IS_SET=true
set +e
for dir_path in "${unit_dirs[@]}"; do
pushd "$dir_path" > /dev/null || continue
terragrunt validate-inputs "${ARGS[@]}"
local exit_code=$?
if [ $exit_code -ne 0 ]; then
final_exit_code=$exit_code
fi
popd > /dev/null
done
[[ $ERREXIT_IS_SET ]] && set -e
exit $final_exit_code
}
function legacy_unit_dirs_from_files {
local -a unit_files=()
local file_with_path
local file_dir
local file_name
if common::is_hook_run_on_whole_repo "$HOOK_ID" "${FILES[@]}"; then
find . -type f -name terragrunt.hcl \
-not -path '*/.terragrunt-cache/*' \
-not -path '*/.terraform/*' |
sort -u | while read -r unit_file; do
dirname "$unit_file"
done
return
fi
for file_with_path in "${FILES[@]}"; do
file_dir=$(dirname "$file_with_path")
file_name=$(basename "$file_with_path")
if [[ $file_name == terragrunt.hcl ]]; then
unit_files+=("$file_with_path")
continue
fi
while read -r unit_file; do
if [[ -n $unit_file ]]; then
unit_files+=("$unit_file")
fi
done < <(find "$file_dir" -type f -name terragrunt.hcl \
-not -path '*/.terragrunt-cache/*' \
-not -path '*/.terraform/*' | sort -u)
done
if [[ ${#unit_files[@]} -eq 0 ]]; then
find . -type f -name terragrunt.hcl \
-not -path '*/.terragrunt-cache/*' \
-not -path '*/.terraform/*' |
sort -u | while read -r unit_file; do
dirname "$unit_file"
done
return
fi
printf '%s\n' "${unit_files[@]}" | sort -u | while read -r unit_file; do
dirname "$unit_file"
done
}
#######################################################################
# Unique part of `common::per_dir_hook`. The function is executed in loop
# on each provided dir path. Run wrapped tool with specified arguments
# Arguments:
# dir_path (string) PATH to dir relative to git repo root.
# Can be used in error logging
# change_dir_in_unique_part (string/false) Modifier which creates
# possibilities to use non-common chdir strategies.
# Availability depends on hook.
# args (array) arguments that configure wrapped tool behavior
# Outputs:
# If failed - print out hook checks status
#######################################################################
function per_dir_hook_unique_part {
# shellcheck disable=SC2034 # Unused var.
local -r dir_path="$1"
# shellcheck disable=SC2034 # Unused var.
local -r change_dir_in_unique_part="$2"
shift 2
local -a -r args=("$@")
# pass the arguments to hook
terragrunt "${SUBCOMMAND[@]}" "${args[@]}"
# return exit code to common::per_dir_hook
local exit_code=$?
return $exit_code
}
#######################################################################
# Unique part of `common::per_dir_hook`. The function is executed one time
# in the root git repo
# Arguments:
# args (array) arguments that configure wrapped tool behavior
#######################################################################
function run_hook_on_whole_repo {
local -a -r args=("$@")
# pass the arguments to hook
terragrunt "${RUN_ALL_SUBCOMMAND[@]}" "${args[@]}"
# return exit code to common::per_dir_hook
local exit_code=$?
return $exit_code
}
[ "${BASH_SOURCE[0]}" != "$0" ] || main "$@"

View file

@ -315,7 +315,7 @@ EOF
all_tf_content=$(find "${full_module_dir}" -regex '.*\.(tf|tofu)' -maxdepth 1 -type f -exec cat {} +) all_tf_content=$(find "${full_module_dir}" -regex '.*\.(tf|tofu)' -maxdepth 1 -type f -exec cat {} +)
if [[ ! $all_tf_content ]]; then if [[ ! $all_tf_content ]]; then
common::colorify "yellow" "Skipping ${full_module_dir} because there are no *.(tf|tofu) files." common::colorify "yellow" "Skipping ${full_module_dir} because there are no .tf or .tofu files."
continue continue
fi fi

View file

@ -360,7 +360,7 @@ getopt() {
} }
_getopt_resolve_abbrev() { _getopt_resolve_abbrev() {
# Resolves an abbrevation from a list of possibilities. # Resolves an abbreviation from a list of possibilities.
# If the abbreviation is unambiguous, echoes the expansion on stdout # If the abbreviation is unambiguous, echoes the expansion on stdout
# and returns 0. If the abbreviation is ambiguous, prints a message on # and returns 0. If the abbreviation is ambiguous, prints a message on
# stderr and returns 1. (For first parse this should convert to exit # stderr and returns 1. (For first parse this should convert to exit