mirror of
https://github.com/tofuutils/pre-commit-opentofu.git
synced 2025-10-15 17:38:54 +02:00
Compare commits
55 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
682111edbb |
||
|
|
a3716be334 |
||
|
|
8ad84a44ef |
||
|
|
430f50f0bd |
||
|
|
93e26a60e7 |
||
|
|
211d65d43d |
||
|
|
16b5e9c289 |
||
|
|
65db8f537f |
||
|
|
f9d6074ab0 |
||
|
|
701ddd21e1 |
||
|
|
ecabde1843 |
||
|
|
f2b0eb603a |
||
|
|
84d857a5ae |
||
|
|
a4ae94e826 |
||
|
|
d581d5f42f |
||
|
|
f81b28692c |
||
|
|
4a08fa44c1 |
||
|
|
b2658a3f8e |
||
|
|
3357820262 |
||
|
|
bac5ee6be0 |
||
|
|
977d08e2d1 |
||
|
|
d94583baf8 |
||
|
|
2bb866f953 |
||
|
|
407a900bbc |
||
|
|
04bfdda8eb | ||
| df886fa772 | |||
|
|
44c7b5dec9 |
||
|
|
b73207253f |
||
|
|
f5f4fdf330 |
||
|
|
5f888bddf6 |
||
|
|
98a556422a |
||
|
|
ed9b22cc37 |
||
|
|
8604934d93 |
||
|
|
16722bff5a |
||
|
|
7eab6411d6 |
||
|
|
da8319297d |
||
|
|
b27ad3a24a |
||
|
|
df38ee3d39 | ||
|
|
10393e2209 |
||
|
|
700b083394 |
||
|
|
6be1b27016 |
||
|
|
f8089e96a8 |
||
|
|
0cbe561817 |
||
|
|
08c520a2f2 | ||
|
|
e625db13ec | ||
|
|
3f2b1f3d25 |
||
|
|
7b4692fe47 | ||
|
|
5af24ae7a6 | ||
|
|
3f2a01a4b8 |
||
|
|
e059c5859b |
||
|
|
81b78c8fd7 | ||
|
|
d167eb9098 |
||
|
|
14fc63eb5b |
||
|
|
d2f129a4be |
||
|
|
fc98a63dd8 |
15 changed files with 175 additions and 106 deletions
10
.github/dependabot.yml
vendored
Normal file
10
.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: /
|
||||||
|
schedule:
|
||||||
|
interval: daily
|
||||||
|
time: "11:00"
|
||||||
|
commit-message:
|
||||||
|
prefix: "gh-actions:"
|
||||||
6
.github/workflows/build-image-test.yaml
vendored
6
.github/workflows/build-image-test.yaml
vendored
|
|
@ -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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
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@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47.0.0
|
||||||
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
|
||||||
|
|
|
||||||
2
.github/workflows/build-image.yaml
vendored
2
.github/workflows/build-image.yaml
vendored
|
|
@ -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
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
|
||||||
2
.github/workflows/pr-title.yml
vendored
2
.github/workflows/pr-title.yml
vendored
|
|
@ -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:
|
||||||
|
|
|
||||||
10
.github/workflows/pre-commit.yaml
vendored
10
.github/workflows/pre-commit.yaml
vendored
|
|
@ -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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
- 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/*
|
||||||
|
|
||||||
|
|
@ -31,16 +31,16 @@ jobs:
|
||||||
curl -L "$(curl -s https://api.github.com/repos/hadolint/hadolint/releases/latest | grep -o -E -m 1 "https://.+?/hadolint-Linux-x86_64")" > hadolint \
|
curl -L "$(curl -s https://api.github.com/repos/hadolint/hadolint/releases/latest | grep -o -E -m 1 "https://.+?/hadolint-Linux-x86_64")" > hadolint \
|
||||||
&& chmod +x hadolint && sudo mv hadolint /usr/bin/
|
&& 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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
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 +49,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:
|
||||||
|
|
|
||||||
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
|
|
@ -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@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
|
||||||
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@ba330626c4750c19d8299de843f05c7aa5574f62 # v5.0.2
|
||||||
with:
|
with:
|
||||||
semantic_version: 18.0.0
|
semantic_version: 18.0.0
|
||||||
extra_plugins: |
|
extra_plugins: |
|
||||||
|
|
|
||||||
2
.github/workflows/stale-actions.yaml
vendored
2
.github/workflows/stale-actions.yaml
vendored
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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(vars)?|hcl)$
|
files: \.((tf|tofu)(vars)?|hcl)$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
|
|
||||||
- id: tofu_fmt
|
- id: tofu_fmt
|
||||||
|
|
@ -12,25 +12,29 @@
|
||||||
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|\.tfvars)$
|
files: \.(tf|tofu)(vars)?$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
|
|
||||||
- id: tofu_docs
|
- id: tofu_docs
|
||||||
name: OpenTofu docs
|
name: OpenTofu docs
|
||||||
description: Inserts input and output documentation into README.md (using terraform-docs).
|
description:
|
||||||
|
Inserts input and output documentation into README.md (using
|
||||||
|
terraform-docs).
|
||||||
require_serial: true
|
require_serial: true
|
||||||
entry: hooks/tofu_docs.sh
|
entry: hooks/tofu_docs.sh
|
||||||
language: script
|
language: script
|
||||||
files: (\.tf|\.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
|
||||||
name: OpenTofu docs (without aggregate type defaults)
|
name: OpenTofu docs (without aggregate type defaults)
|
||||||
description: Inserts input and output documentation into README.md (using terraform-docs). Identical to terraform_docs.
|
description:
|
||||||
|
Inserts input and output documentation into README.md (using
|
||||||
|
terraform-docs). Identical to terraform_docs.
|
||||||
require_serial: true
|
require_serial: true
|
||||||
entry: hooks/tofu_docs.sh
|
entry: hooks/tofu_docs.sh
|
||||||
language: script
|
language: script
|
||||||
files: (\.tf)$
|
files: \.(tf|tofu)$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
|
|
||||||
- id: tofu_docs_replace
|
- id: tofu_docs_replace
|
||||||
|
|
@ -39,7 +43,7 @@
|
||||||
require_serial: true
|
require_serial: true
|
||||||
entry: hooks/tofu_docs_replace.py
|
entry: hooks/tofu_docs_replace.py
|
||||||
language: python
|
language: python
|
||||||
files: (\.tf)$
|
files: \.(tf|tofu)$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
|
|
||||||
- id: tofu_validate
|
- id: tofu_validate
|
||||||
|
|
@ -48,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|\.tfvars)$
|
files: \.(tf|tofu)(vars)?$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
|
|
||||||
- id: tofu_providers_lock
|
- id: tofu_providers_lock
|
||||||
|
|
@ -66,12 +70,13 @@
|
||||||
require_serial: true
|
require_serial: true
|
||||||
entry: hooks/tofu_tflint.sh
|
entry: hooks/tofu_tflint.sh
|
||||||
language: script
|
language: script
|
||||||
files: (\.tf|\.tfvars)$
|
files: \.(tf|tofu)(vars)?$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
|
|
||||||
- id: terragrunt_fmt
|
- id: terragrunt_fmt
|
||||||
name: Terragrunt fmt
|
name: Terragrunt fmt
|
||||||
description: Rewrites all Terragrunt configuration files to a canonical format.
|
description:
|
||||||
|
Rewrites all Terragrunt configuration files to a canonical format.
|
||||||
entry: hooks/terragrunt_fmt.sh
|
entry: hooks/terragrunt_fmt.sh
|
||||||
language: script
|
language: script
|
||||||
files: (\.hcl)$
|
files: (\.hcl)$
|
||||||
|
|
@ -87,18 +92,20 @@
|
||||||
|
|
||||||
- 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: Static analysis of OpenTofu templates to spot potential security issues.
|
description:
|
||||||
|
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(vars)?$
|
files: \.(tf|tofu)(vars)?$
|
||||||
language: script
|
language: script
|
||||||
|
|
||||||
- id: tofu_trivy
|
- id: tofu_trivy
|
||||||
name: OpenTofu validate with trivy
|
name: OpenTofu validate with trivy
|
||||||
description: Static analysis of OpenTofu templates to spot potential security issues.
|
description:
|
||||||
|
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(vars)?$
|
files: \.(tf|tofu)(vars)?$
|
||||||
language: script
|
language: script
|
||||||
|
|
||||||
- id: checkov
|
- id: checkov
|
||||||
|
|
@ -118,7 +125,7 @@
|
||||||
entry: hooks/tofu_checkov.sh
|
entry: hooks/tofu_checkov.sh
|
||||||
language: script
|
language: script
|
||||||
always_run: false
|
always_run: false
|
||||||
files: \.tf$
|
files: \.(tf|tofu)$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
require_serial: true
|
require_serial: true
|
||||||
|
|
||||||
|
|
@ -138,7 +145,7 @@
|
||||||
description: Runs terrascan on OpenTofu templates.
|
description: Runs terrascan on OpenTofu templates.
|
||||||
language: script
|
language: script
|
||||||
entry: hooks/terrascan.sh
|
entry: hooks/terrascan.sh
|
||||||
files: \.tf$
|
files: \.(tf|tofu)$
|
||||||
exclude: \.terraform\/.*$
|
exclude: \.terraform\/.*$
|
||||||
require_serial: true
|
require_serial: true
|
||||||
|
|
||||||
|
|
@ -149,5 +156,5 @@
|
||||||
entry: hooks/tfupdate.sh
|
entry: hooks/tfupdate.sh
|
||||||
args:
|
args:
|
||||||
- --args=terraform
|
- --args=terraform
|
||||||
files: \.tf$
|
files: \.(tf|tofu)$
|
||||||
require_serial: true
|
require_serial: true
|
||||||
|
|
|
||||||
34
CHANGELOG.md
34
CHANGELOG.md
|
|
@ -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.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)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* make release ([e625db1](https://github.com/tofuutils/pre-commit-opentofu/commit/e625db13ec285e132f43cdf6e5aa3f3272e45451))
|
||||||
|
|
||||||
|
# [2.1.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v2.0.0...v2.1.0) (2024-10-16)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* spport .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)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **tofu:** add handling for missing tofu binary in Docker image This commit introduces logic to gracefully handle the case when the tofu binary is not found in the Docker image, improving the overall user experience. BREAKING CHANGE: The previous behavior of the application when the tofu binary was missing may have caused unexpected crashes. ([14fc63e](https://github.com/tofuutils/pre-commit-opentofu/commit/14fc63eb5b04e3ad1525d06e437b15935841775f))
|
||||||
|
|
||||||
|
|
||||||
|
### BREAKING CHANGES
|
||||||
|
|
||||||
|
* **tofu:** The previous behavior of the application when the tofu binary was missing may have caused unexpected crashes."
|
||||||
|
|
||||||
## [1.0.4](https://github.com/tofuutils/pre-commit-opentofu/compare/v1.0.3...v1.0.4) (2024-09-21)
|
## [1.0.4](https://github.com/tofuutils/pre-commit-opentofu/compare/v1.0.3...v1.0.4) (2024-09-21)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
10
Dockerfile
10
Dockerfile
|
|
@ -14,18 +14,18 @@ RUN apk add --no-cache \
|
||||||
setuptools
|
setuptools
|
||||||
|
|
||||||
ARG PRE_COMMIT_VERSION=${PRE_COMMIT_VERSION:-latest}
|
ARG PRE_COMMIT_VERSION=${PRE_COMMIT_VERSION:-latest}
|
||||||
ARG TOFU_VERSION=${TOFU_VERSION:-1.6.1}
|
ARG TOFU_VERSION=${TOFU_VERSION:-1.9.0}
|
||||||
|
|
||||||
# Install pre-commit
|
# Install pre-commit
|
||||||
RUN [ ${PRE_COMMIT_VERSION} = "latest" ] && pip3 install --no-cache-dir pre-commit \
|
RUN [ ${PRE_COMMIT_VERSION} = "latest" ] && pip3 install --no-cache-dir pre-commit \
|
||||||
|| pip3 install --no-cache-dir pre-commit==${PRE_COMMIT_VERSION}
|
|| pip3 install --no-cache-dir pre-commit==${PRE_COMMIT_VERSION}
|
||||||
|
|
||||||
|
|
||||||
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 \
|
&& unzip tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip -d /usr/bin/ \
|
||||||
&& mv tofu /usr/bin/tofu
|
&& rm "tofu_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip" \
|
||||||
|
&& rm "tofu_${TOFU_VERSION}_SHA256SUMS"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Install tools
|
# Install tools
|
||||||
|
|
@ -208,6 +208,7 @@ COPY --from=builder \
|
||||||
/usr/local/bin/pre-commit \
|
/usr/local/bin/pre-commit \
|
||||||
# Hooks and terraform binaries
|
# Hooks and terraform binaries
|
||||||
/bin_dir/ \
|
/bin_dir/ \
|
||||||
|
/usr/bin/tofu \
|
||||||
/usr/local/bin/checkov* \
|
/usr/local/bin/checkov* \
|
||||||
/usr/bin/
|
/usr/bin/
|
||||||
# Copy pre-commit packages
|
# Copy pre-commit packages
|
||||||
|
|
@ -234,3 +235,4 @@ 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" ]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,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:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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")"
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ function tofu_docs {
|
||||||
#
|
#
|
||||||
if $create_if_not_exist && [[ ! -f "$text_file" ]]; then
|
if $create_if_not_exist && [[ ! -f "$text_file" ]]; then
|
||||||
dir_have_tf_files="$(
|
dir_have_tf_files="$(
|
||||||
find . -maxdepth 1 -type f | sed 's|.*\.||' | sort -u | grep -oE '^tf$|^tfvars$' ||
|
find . -maxdepth 1 -type f | sed 's|.*\.||' | sort -u | grep -oE '^tofu|^tf$|^tfvars$' ||
|
||||||
exit 0
|
exit 0
|
||||||
)"
|
)"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,30 +7,41 @@ import sys
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="""Run terraform-docs on a set of files. Follows the standard convention of
|
description="""Run terraform-docs on a set of files. Follows the standard convention of
|
||||||
pulling the documentation from main.tf in order to replace the entire
|
pulling the documentation from main.(tf|tofu) in order to replace the entire
|
||||||
README.md file each time."""
|
README.md file each time."""
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--dest', dest='dest', default='README.md',
|
"--dest",
|
||||||
|
dest="dest",
|
||||||
|
default="README.md",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--sort-inputs-by-required', dest='sort', action='store_true',
|
"--sort-inputs-by-required",
|
||||||
help='[deprecated] use --sort-by-required instead',
|
dest="sort",
|
||||||
|
action="store_true",
|
||||||
|
help="[deprecated] use --sort-by-required instead",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--sort-by-required', dest='sort', action='store_true',
|
"--sort-by-required",
|
||||||
|
dest="sort",
|
||||||
|
action="store_true",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--with-aggregate-type-defaults', dest='aggregate', action='store_true',
|
"--with-aggregate-type-defaults",
|
||||||
help='[deprecated]',
|
dest="aggregate",
|
||||||
|
action="store_true",
|
||||||
|
help="[deprecated]",
|
||||||
)
|
)
|
||||||
parser.add_argument('filenames', nargs='*', help='Filenames to check.')
|
parser.add_argument("filenames", nargs="*", help="Filenames to check.")
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
|
|
||||||
dirs = []
|
dirs = []
|
||||||
for filename in args.filenames:
|
for filename in args.filenames:
|
||||||
if (os.path.realpath(filename) not in dirs and
|
if os.path.realpath(filename) not in dirs and (
|
||||||
(filename.endswith(".tf") or filename.endswith(".tfvars"))):
|
filename.endswith(".tf")
|
||||||
|
or filename.endswith(".tofu")
|
||||||
|
or filename.endswith(".tfvars")
|
||||||
|
):
|
||||||
dirs.append(os.path.dirname(filename))
|
dirs.append(os.path.dirname(filename))
|
||||||
|
|
||||||
retval = 0
|
retval = 0
|
||||||
|
|
@ -38,12 +49,12 @@ def main(argv=None):
|
||||||
for dir in dirs:
|
for dir in dirs:
|
||||||
try:
|
try:
|
||||||
procArgs = []
|
procArgs = []
|
||||||
procArgs.append('terraform-docs')
|
procArgs.append("terraform-docs")
|
||||||
if args.sort:
|
if args.sort:
|
||||||
procArgs.append('--sort-by-required')
|
procArgs.append("--sort-by-required")
|
||||||
procArgs.append('md')
|
procArgs.append("md")
|
||||||
procArgs.append("./{dir}".format(dir=dir))
|
procArgs.append("./{dir}".format(dir=dir))
|
||||||
procArgs.append('>')
|
procArgs.append(">")
|
||||||
procArgs.append("./{dir}/{dest}".format(dir=dir, dest=args.dest))
|
procArgs.append("./{dir}/{dest}".format(dir=dir, dest=args.dest))
|
||||||
subprocess.check_call(" ".join(procArgs), shell=True)
|
subprocess.check_call(" ".join(procArgs), shell=True)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
|
|
@ -52,5 +63,5 @@ def main(argv=None):
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == "__main__":
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
|
||||||
|
|
@ -312,10 +312,10 @@ EOF
|
||||||
|
|
||||||
# Read content of all OpenTofu files
|
# Read content of all OpenTofu files
|
||||||
# shellcheck disable=SC2207
|
# shellcheck disable=SC2207
|
||||||
all_tf_content=$(find "${full_module_dir}" -name '*.tf' -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 files."
|
common::colorify "yellow" "Skipping ${full_module_dir} because there are no *.(tf|tofu) files."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue