From 7f963c5906da6f8a6e6aa2f12c7efca0ee432b47 Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 00:18:19 +0100 Subject: [PATCH 01/10] feat: rename pre-commit-terraform to pre-commit-opentofu --- README.md | 61 ++++++++++++++++++++----------------------------------- setup.py | 4 ++-- 2 files changed, 24 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index b4eef7d..7126a24 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,10 @@ -# Collection of git hooks for Terraform to be used with [pre-commit framework](http://pre-commit.com/) +# Collection of git hooks for OpenTofu to be used with [pre-commit framework](http://pre-commit.com/) -[![Github tag](https://img.shields.io/github/tag/antonbabenko/pre-commit-terraform.svg)](https://github.com/antonbabenko/pre-commit-terraform/releases) ![maintenance status](https://img.shields.io/maintenance/yes/2023.svg) [![Help Contribute to Open Source](https://www.codetriage.com/antonbabenko/pre-commit-terraform/badges/users.svg)](https://www.codetriage.com/antonbabenko/pre-commit-terraform) +[![Github tag](https://img.shields.io/github/tag/tofuutils/pre-commit-opentofu.svg)](https://github.com/tofuutils/pre-commit-opentofu/releases) ![maintenance status](https://img.shields.io/maintenance/yes/2023.svg) [![Help Contribute to Open Source](https://www.codetriage.com/tofuutils/pre-commit-opentofu/badges/users.svg)](https://www.codetriage.com/tofuutils/pre-commit-opentofu) -[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md) - -Want to contribute? Check [open issues](https://github.com/antonbabenko/pre-commit-terraform/issues?q=label%3A%22good+first+issue%22+is%3Aopen+sort%3Aupdated-desc) and [contributing notes](/.github/CONTRIBUTING.md). +Want to contribute? Check [open issues](https://github.com/tofuutils/pre-commit-opentofu/issues?q=label%3A%22good+first+issue%22+is%3Aopen+sort%3Aupdated-desc) and [contributing notes](/.github/CONTRIBUTING.md). ## Sponsors - - - -
-env0 - -Automated provisioning of Terraform workflows and Infrastructure as Code. - -
-infracost - - - -Cloud cost estimates for Terraform. - If you are using `pre-commit-terraform` already or want to support its development and [many other open-source projects](https://github.com/antonbabenko/terraform-aws-devops), please become a [GitHub Sponsor](https://github.com/sponsors/antonbabenko)! @@ -95,10 +78,10 @@ If you are using `pre-commit-terraform` already or want to support its developme ```bash TAG=latest -docker pull ghcr.io/antonbabenko/pre-commit-terraform:$TAG +docker pull ghcr.io/tofuutils/pre-commit-opentofu:$TAG ``` -All available tags [here](https://github.com/antonbabenko/pre-commit-terraform/pkgs/container/pre-commit-terraform/versions). +All available tags [here](https://github.com/tofuutils/pre-commit-opentofu/pkgs/container/pre-commit-opentofu/versions). **Build from scratch**: @@ -108,7 +91,7 @@ All available tags [here](https://github.com/antonbabenko/pre-commit-terraform/p When hooks-related `--build-arg`s are not specified, only the latest version of `pre-commit` and `terraform` will be installed. ```bash -git clone git@github.com:antonbabenko/pre-commit-terraform.git +git clone git@github.com:tofuutils/pre-commit-opentofu.git cd pre-commit-terraform # Install the latest versions of all the tools docker build -t pre-commit-terraform --build-arg INSTALL_ALL=true . @@ -231,8 +214,8 @@ Step into the repository you want to have the pre-commit hooks installed and run git init cat < .pre-commit-config.yaml repos: -- repo: https://github.com/antonbabenko/pre-commit-terraform - rev: # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases +- repo: https://github.com/tofuutils/pre-commit-opentofu + rev: # Get the latest from: https://github.com/tofuutils/pre-commit-opentofu/releases hooks: - id: terraform_fmt - id: terraform_docs @@ -247,20 +230,20 @@ Execute this command to run `pre-commit` on all files in the repository (not onl pre-commit run -a ``` -Or, using Docker ([available tags](https://github.com/antonbabenko/pre-commit-terraform/pkgs/container/pre-commit-terraform/versions)): +Or, using Docker ([available tags](https://github.com/tofuutils/pre-commit-opentofu/pkgs/container/pre-commit-opentofu/versions)): > **Note**: This command uses your user id and group id for the docker container to use to access the local files. If the files are owned by another user, update the `USERID` environment variable. See [File Permissions section](#file-permissions) for more information. ```bash TAG=latest -docker run -e "USERID=$(id -u):$(id -g)" -v $(pwd):/lint -w /lint ghcr.io/antonbabenko/pre-commit-terraform:$TAG run -a +docker run -e "USERID=$(id -u):$(id -g)" -v $(pwd):/lint -w /lint ghcr.io/tofuutils/pre-commit-opentofu:$TAG run -a ``` Execute this command to list the versions of the tools in Docker: ```bash TAG=latest -docker run --rm --entrypoint cat ghcr.io/antonbabenko/pre-commit-terraform:$TAG /usr/bin/tools_versions_info +docker run --rm --entrypoint cat ghcr.io/tofuutils/pre-commit-opentofu:$TAG /usr/bin/tools_versions_info ``` ## Available Hooks @@ -273,7 +256,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform | `checkov` and `terraform_checkov` | [checkov](https://github.com/bridgecrewio/checkov) static analysis of terraform templates to spot potential security issues. [Hook notes](#checkov-deprecated-and-terraform_checkov) | `checkov`
Ubuntu deps: `python3`, `python3-pip` | | `infracost_breakdown` | Check how much your infra costs with [infracost](https://github.com/infracost/infracost). [Hook notes](#infracost_breakdown) | `infracost`, `jq`, [Infracost API key](https://www.infracost.io/docs/#2-get-api-key) | | `terraform_docs` | Inserts input and output documentation into `README.md`. Recommended. [Hook notes](#terraform_docs) | `terraform-docs` | -| `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md. **DEPRECATED**, see [#248](https://github.com/antonbabenko/pre-commit-terraform/issues/248). [Hook notes](#terraform_docs_replace-deprecated) | `python3`, `terraform-docs` | +| `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md. **DEPRECATED**, see [#248](https://github.com/tofuutils/pre-commit-opentofu/issues/248). [Hook notes](#terraform_docs_replace-deprecated) | `python3`, `terraform-docs` | | `terraform_docs_without_`
`aggregate_type_defaults` | Inserts input and output documentation into `README.md` without aggregate type defaults. Hook notes same as for [terraform_docs](#terraform_docs) | `terraform-docs` | | `terraform_fmt` | Reformat all Terraform configuration files to a canonical format. [Hook notes](#terraform_fmt) | - | | `terraform_providers_lock` | Updates provider signatures in [dependency lock files](https://www.terraform.io/docs/cli/commands/providers/lock.html). [Hook notes](#terraform_providers_lock) | - | @@ -288,7 +271,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform | `tfupdate` | [tfupdate](https://github.com/minamijoyo/tfupdate) Update version constraints of Terraform core, providers, and modules. [Hook notes](#tfupdate) | `tfupdate` | -Check the [source file](https://github.com/antonbabenko/pre-commit-terraform/blob/master/.pre-commit-hooks.yaml) to know arguments used for each hook. +Check the [source file](https://github.com/tofuutils/pre-commit-opentofu/blob/master/.pre-commit-hooks.yaml) to know arguments used for each hook. ## Hooks usage notes and examples @@ -856,7 +839,7 @@ To replicate functionality in `terraform_docs` hook: `terraform_validate` hook will try to reinitialize them before running the `terraform validate` command. - **Warning**: If you use Terraform workspaces, DO NOT use this option ([details](https://github.com/antonbabenko/pre-commit-terraform/issues/203#issuecomment-918791847)). Consider the first option, or wait for [`force-init`](https://github.com/antonbabenko/pre-commit-terraform/issues/224) option implementation. + **Warning**: If you use Terraform workspaces, DO NOT use this option ([details](https://github.com/tofuutils/pre-commit-opentofu/issues/203#issuecomment-918791847)). Consider the first option, or wait for [`force-init`](https://github.com/tofuutils/pre-commit-opentofu/issues/224) option implementation. 4. `terraform_validate` in a repo with Terraform module, written using Terraform 0.15+ and which uses provider `configuration_aliases` ([Provider Aliases Within Modules](https://www.terraform.io/language/modules/develop/providers#provider-aliases-within-modules)), errors out. @@ -994,7 +977,7 @@ The [recommended command](#4-run) to run the Docker container is: ```bash TAG=latest -docker run -e "USERID=$(id -u):$(id -g)" -v $(pwd):/lint -w /lint ghcr.io/antonbabenko/pre-commit-terraform:$TAG run -a +docker run -e "USERID=$(id -u):$(id -g)" -v $(pwd):/lint -w /lint ghcr.io/tofuutils/pre-commit-opentofu:$TAG run -a ``` which uses your current session's user ID and group ID to set the variable in the run command. Without this setting, you may find files and directories owned by `root` in your local repository. @@ -1038,7 +1021,7 @@ Finally, you can execute `docker run` with an additional volume mount so that th # run pre-commit-terraform with docker # adding volume for .netrc file # .netrc needs to be in /root/ dir -docker run --rm -e "USERID=$(id -u):$(id -g)" -v ~/.netrc:/root/.netrc -v $(pwd):/lint -w /lint ghcr.io/antonbabenko/pre-commit-terraform:latest run -a +docker run --rm -e "USERID=$(id -u):$(id -g)" -v ~/.netrc:/root/.netrc -v $(pwd):/lint -w /lint ghcr.io/tofuutils/pre-commit-opentofu:latest run -a ``` ## Authors @@ -1046,16 +1029,16 @@ docker run --rm -e "USERID=$(id -u):$(id -g)" -v ~/.netrc:/root/.netrc -v $(pwd) This repository is managed by [Anton Babenko](https://github.com/antonbabenko) with help from these awesome contributors: - - + + - + - - - Star History Chart + + + Star History Chart diff --git a/setup.py b/setup.py index 2d88425..3168c93 100644 --- a/setup.py +++ b/setup.py @@ -3,9 +3,9 @@ from setuptools import setup setup( - name='pre-commit-terraform', + name='pre-commit-opentofu', description='Pre-commit hooks for terraform_docs_replace', - url='https://github.com/antonbabenko/pre-commit-terraform', + url='https://github.com/tofuutils/pre-commit-opentofu', version_format='{tag}+{gitsha}', author='Contributors', From 2e537a9cd47bcf8c38569e6bf62c837120afc204 Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 00:29:39 +0100 Subject: [PATCH 02/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt II --- .github/CONTRIBUTING.md | 7 +- .github/FUNDING.yml | 4 +- CHANGELOG.md | 947 +----------------------------- LICENSE | 1 + README.md | 10 +- hooks/__init__.py | 2 +- hooks/_common.sh | 2 +- hooks/terraform_providers_lock.sh | 2 +- hooks/terraform_tfsec.sh | 2 +- tools/entrypoint.sh | 2 +- 10 files changed, 16 insertions(+), 963 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 388bf37..d72b0a3 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -100,12 +100,13 @@ sudo rm -rf tests/results ## Add new hook -You can use [this PR](https://github.com/antonbabenko/pre-commit-terraform/pull/252) as an example. +You can use [this PR](https://github.com/tofuutils/pre-commit-opentofu/pull/1) as an example. ### Before write code 1. Try to figure out future hook usage. -2. Confirm the concept with [Anton Babenko](https://github.com/antonbabenko). +2. Confirm the concept with one of the following people: [Alexander Sharov](https://github.com/kvendingoldo), [Nikolay Mishin](https://github.com/Nmishin), [Anastasiia Kozlova](https://github.com/anastasiiakozlova245). + ### Prepare basic documentation @@ -129,7 +130,7 @@ You can use [this PR](https://github.com/antonbabenko/pre-commit-terraform/pull/ ```yaml repos: - - repo: https://github.com/antonbabenko/pre-commit-terraform # Your repo + - repo: https://github.com/tofuutils/pre-commit-opentofu # Your repo rev: 3d76da3885e6a33d59527eff3a57d246dfb66620 # Your commit SHA hooks: - id: terraform_docs # New hook name diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 9fdcfce..55e8f24 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ -github: [antonbabenko] -custom: https://www.paypal.me/antonbabenko +github: [kvendingoldo] +custom: https://www.paypal.me/kvendingoldo diff --git a/CHANGELOG.md b/CHANGELOG.md index bd283b1..8a922d3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,952 +2,9 @@ All notable changes to this project will be documented in this file. -# [1.86.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.85.0...v1.86.0) (2023-12-21) +# [1.0.0](https://github.com/tofuutils/pre-commit-opentofu/compare/v1.0.0) (2023-12-21) ### Features -* **`terraform_docs`:** Add `terraform-docs` default markers support and describe how to migrate to them ([#609](https://github.com/antonbabenko/pre-commit-terraform/issues/609)) ([4a0e1fe](https://github.com/antonbabenko/pre-commit-terraform/commit/4a0e1fed008230b65085da0e42b7695bc4e0a5f1)) - -# [1.85.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.84.0...v1.85.0) (2023-12-15) - - -### Features - -* **trivy:** Add `terraform_trivy` hook and deprecate `terraform_tfsec` ([#606](https://github.com/antonbabenko/pre-commit-terraform/issues/606)) ([f3c819a](https://github.com/antonbabenko/pre-commit-terraform/commit/f3c819a747662d1257fa6989318d6ede5fabaff3)) - -# [1.84.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.83.6...v1.84.0) (2023-12-12) - - -### Features - -* **deps:** Bump Python version in docker image from 3.11.5 to v3.12.0 ([#597](https://github.com/antonbabenko/pre-commit-terraform/issues/597)) ([28e3cde](https://github.com/antonbabenko/pre-commit-terraform/commit/28e3cde152370bcc5b38e82beb0345299f8c511d)) - -## [1.83.6](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.83.5...v1.83.6) (2023-11-16) - - -### Bug Fixes - -* **`terraform_validate`:** Run `terraform init` on "Missing required provider" error ([#586](https://github.com/antonbabenko/pre-commit-terraform/issues/586)) ([6e2bb2e](https://github.com/antonbabenko/pre-commit-terraform/commit/6e2bb2e2a12528903d8b8a21f2924473e498385a)) - -## [1.83.5](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.83.4...v1.83.5) (2023-10-11) - - -### Bug Fixes - -* Suppress duplicate error messages in `terraform_validate` ([#577](https://github.com/antonbabenko/pre-commit-terraform/issues/577)) ([4ea6b14](https://github.com/antonbabenko/pre-commit-terraform/commit/4ea6b14c6fdf48e33fa6e116cbe332bba0888bbb)) - -## [1.83.4](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.83.3...v1.83.4) (2023-09-22) - - -### Bug Fixes - -* Fix terraform_wrapper_module_for_each for when resource name contains 'variable' ([#573](https://github.com/antonbabenko/pre-commit-terraform/issues/573)) ([941177e](https://github.com/antonbabenko/pre-commit-terraform/commit/941177e066e8de255f58f0a5afbda72995eb3f08)) - -## [1.83.3](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.83.2...v1.83.3) (2023-09-15) - - -### Bug Fixes - -* Run `terraform_tfsec` only on terraform code changes ([#571](https://github.com/antonbabenko/pre-commit-terraform/issues/571)) ([4253162](https://github.com/antonbabenko/pre-commit-terraform/commit/42531626144fb8cdca3d5750c7206393f501feb4)) - -## [1.83.2](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.83.1...v1.83.2) (2023-09-04) - - -### Bug Fixes - -* Extend `terraform_validate` `--retry-once-with-cleanup` errors list ([#566](https://github.com/antonbabenko/pre-commit-terraform/issues/566)) ([19188e5](https://github.com/antonbabenko/pre-commit-terraform/commit/19188e5c384a1803bca607e4e79faf61cc55a5b9)) - -## [1.83.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.83.0...v1.83.1) (2023-09-04) - - -### Bug Fixes - -* Fixed ordering issue in terraform_wrapper_module_for_each hook ([#565](https://github.com/antonbabenko/pre-commit-terraform/issues/565)) ([dc12be1](https://github.com/antonbabenko/pre-commit-terraform/commit/dc12be1faff4b73a3fc9bd62296c40a351597a20)) - -# [1.83.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.82.0...v1.83.0) (2023-08-25) - - -### Features - -* Skip legacy modules (with provider block) in terraform_wrapper_module_for_each hook ([#560](https://github.com/antonbabenko/pre-commit-terraform/issues/560)) ([456cc76](https://github.com/antonbabenko/pre-commit-terraform/commit/456cc7616ac4facc3392c51ed9606a7535f8fd0f)) - -# [1.82.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.81.2...v1.82.0) (2023-08-15) - - -### Features - -* **docker:** Add ssh-client to Docker image to access private modules via ssh ([#553](https://github.com/antonbabenko/pre-commit-terraform/issues/553)) ([1d76157](https://github.com/antonbabenko/pre-commit-terraform/commit/1d76157c9d67a2cbc1b08a4d7bc5ad53a3b663e7)) - -## [1.81.2](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.81.1...v1.81.2) (2023-08-10) - - -### Bug Fixes - -* Fix terraform_wrapper_module_for_each hook heredoc vars defaults ([#554](https://github.com/antonbabenko/pre-commit-terraform/issues/554)) ([6fd4263](https://github.com/antonbabenko/pre-commit-terraform/commit/6fd4263f599ff3318cc2095dde03a312bb617511)) - -## [1.81.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.81.0...v1.81.1) (2023-08-10) - - -### Bug Fixes - -* Fix the terraform_wrapper_module_for_each hook for modules without outputs or variables ([#552](https://github.com/antonbabenko/pre-commit-terraform/issues/552)) ([f24b3fa](https://github.com/antonbabenko/pre-commit-terraform/commit/f24b3fab71b248c4be75ec378c43e6921053491a)) - -# [1.81.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.80.0...v1.81.0) (2023-06-12) - - -### Features - -* Speedup `terraform_validate` - firstly try run validate without checking is `.terraform/` is valid ([#524](https://github.com/antonbabenko/pre-commit-terraform/issues/524)) ([d0d08ac](https://github.com/antonbabenko/pre-commit-terraform/commit/d0d08ac63cebd23e4ee7ff58fb91ea20c398ab69)) - -# [1.80.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.79.1...v1.80.0) (2023-05-30) - - -### Features - -* **`terraform_providers_lock`:** Add `--mode` option and deprecate previous workflow ([#528](https://github.com/antonbabenko/pre-commit-terraform/issues/528)) ([2426b52](https://github.com/antonbabenko/pre-commit-terraform/commit/2426b527aeee39aad0386cbbd734747d883ed7b6)) - -## [1.79.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.79.0...v1.79.1) (2023-05-09) - - -### Bug Fixes - -* Fix `terraform_providers_lock` hook broken in v1.79.0 ([#521](https://github.com/antonbabenko/pre-commit-terraform/issues/521)) ([6bfc5bf](https://github.com/antonbabenko/pre-commit-terraform/commit/6bfc5bf7670a6d9fbf21d1a686fdaa941ab34aa6)) - -# [1.79.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.78.0...v1.79.0) (2023-05-08) - - -### Features - -* TFLint: Add `--hook-config=--delegate-chdir` to use `tflint -chdir` ([#512](https://github.com/antonbabenko/pre-commit-terraform/issues/512)) ([1e9debc](https://github.com/antonbabenko/pre-commit-terraform/commit/1e9debc02f558156823fc1ddd5cf2b48b1593167)) - -# [1.78.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.77.4...v1.78.0) (2023-04-28) - - -### Features - -* **ci:** Build multi-arch Docker images (`amd64`, `arm64`) ([#496](https://github.com/antonbabenko/pre-commit-terraform/issues/496)) ([923c2c6](https://github.com/antonbabenko/pre-commit-terraform/commit/923c2c6a1e093620980790e864801f48a13ecf57)) - -## [1.77.4](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.77.3...v1.77.4) (2023-04-28) - - -### Bug Fixes - -* Speed up x2 TFLint hook execution in dirs with violations ([#514](https://github.com/antonbabenko/pre-commit-terraform/issues/514)) ([49974ab](https://github.com/antonbabenko/pre-commit-terraform/commit/49974ab9ef37e199d65778e6055aaf8130c6a875)) - -## [1.77.3](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.77.2...v1.77.3) (2023-04-21) - - -### Bug Fixes - -* Updates all dependencies used in Dockerfile and fix Docker image ([#507](https://github.com/antonbabenko/pre-commit-terraform/issues/507)) ([dc177fe](https://github.com/antonbabenko/pre-commit-terraform/commit/dc177fe29ed250fbb98702248c7de232bdb75f58)) - -## [1.77.2](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.77.1...v1.77.2) (2023-04-09) - - -### Bug Fixes - -* Fixed spacing in `terraform_wrapper_module_for_each` hook ([#503](https://github.com/antonbabenko/pre-commit-terraform/issues/503)) ([ddc0d81](https://github.com/antonbabenko/pre-commit-terraform/commit/ddc0d81d31a2571de95246b9970216ae0e4432c4)) - -## [1.77.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.77.0...v1.77.1) (2023-02-03) - - -### Bug Fixes - -* Pass command line arguments to tflint init ([#487](https://github.com/antonbabenko/pre-commit-terraform/issues/487)) ([29a8c00](https://github.com/antonbabenko/pre-commit-terraform/commit/29a8c00251e16941059df0f460b1e55890d4d7b5)) - -# [1.77.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.76.1...v1.77.0) (2022-11-26) - - -### Features - -* Add `--retry-once-with-cleanup` to `terraform_validate` ([#441](https://github.com/antonbabenko/pre-commit-terraform/issues/441)) ([96fe3ef](https://github.com/antonbabenko/pre-commit-terraform/commit/96fe3ef6577705ee72ae33cba5f366ce32b9a5f7)) - -## [1.76.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.76.0...v1.76.1) (2022-11-26) - - -### Bug Fixes - -* Describe migration instructions from `terraform_docs_replace` ([#451](https://github.com/antonbabenko/pre-commit-terraform/issues/451)) ([a8bcaa7](https://github.com/antonbabenko/pre-commit-terraform/commit/a8bcaa7975175679f2da0a5d1379f0e20446a2f9)) - -# [1.76.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.75.0...v1.76.0) (2022-10-06) - - -### Features - -* Add support for version constraints in `tfupdate` ([#437](https://github.com/antonbabenko/pre-commit-terraform/issues/437)) ([a446642](https://github.com/antonbabenko/pre-commit-terraform/commit/a4466425fb486257cfc672094d92b0fb04fdfe93)) - -# [1.75.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.74.2...v1.75.0) (2022-09-07) - - -### Features - -* Allow running container as non-root UID/GID for ownership issues (docker) ([#433](https://github.com/antonbabenko/pre-commit-terraform/issues/433)) ([abc2570](https://github.com/antonbabenko/pre-commit-terraform/commit/abc2570e42d3b01b56d34a474eedbf13063d3c31)) - -## [1.74.2](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.74.1...v1.74.2) (2022-09-02) - - -### Bug Fixes - -* Fixed url for wrappers in generated README (terraform_wrapper_module_for_each) ([#429](https://github.com/antonbabenko/pre-commit-terraform/issues/429)) ([fe29c6c](https://github.com/antonbabenko/pre-commit-terraform/commit/fe29c6c71abf31e5e7fbba6ed1d3555971e89ee4)) - -## [1.74.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.74.0...v1.74.1) (2022-07-13) - - -### Bug Fixes - -* Passed scenario in `terraform_docs` hook now works as expected ([7ac2736](https://github.com/antonbabenko/pre-commit-terraform/commit/7ac2736ab9544455b06fb66f2fb40d3609a010b6)) - -# [1.74.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.73.0...v1.74.0) (2022-07-12) - - -### Bug Fixes - -* Add `--env-vars`, deprecate `--envs` ([#410](https://github.com/antonbabenko/pre-commit-terraform/issues/410)) ([2b35cad](https://github.com/antonbabenko/pre-commit-terraform/commit/2b35cad50fd7fe1c662cab1bfaab2a4ef7baa3c9)) -* Add `--tf-init-args`, deprecate `--init-args` ([#407](https://github.com/antonbabenko/pre-commit-terraform/issues/407)) ([c4f8251](https://github.com/antonbabenko/pre-commit-terraform/commit/c4f8251d302260953c62a6b2116ea89584ce04a6)) - - -### Features - -* Add support for set env vars inside hook runtime ([#408](https://github.com/antonbabenko/pre-commit-terraform/issues/408)) ([d490231](https://github.com/antonbabenko/pre-commit-terraform/commit/d4902313ce11cc12c738397463f307b830a9ba3e)) -* Allow `terraform_providers_lock` specify terraform init args ([#406](https://github.com/antonbabenko/pre-commit-terraform/issues/406)) ([32b232f](https://github.com/antonbabenko/pre-commit-terraform/commit/32b232f039ceee24b2db8e09de57047c78c6005b)) -* Suppress color for all hooks if `PRE_COMMIT_COLOR=never` set ([#409](https://github.com/antonbabenko/pre-commit-terraform/issues/409)) ([b12f0c6](https://github.com/antonbabenko/pre-commit-terraform/commit/b12f0c662c4ebd104b27880fc380854590c0ca22)) - -# [1.73.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.72.2...v1.73.0) (2022-06-27) - - -### Features - -* Add __GIT_WORKING_DIR__ to terraform_checkov ([#399](https://github.com/antonbabenko/pre-commit-terraform/issues/399)) ([ae88ed7](https://github.com/antonbabenko/pre-commit-terraform/commit/ae88ed73cfb63398270608d4e68f46bb4424f150)) - -## [1.72.2](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.72.1...v1.72.2) (2022-06-21) - - -### Bug Fixes - -* Pre-commit-terraform terraform_validate hook ([#401](https://github.com/antonbabenko/pre-commit-terraform/issues/401)) ([d9f482c](https://github.com/antonbabenko/pre-commit-terraform/commit/d9f482c0c6fa0bd464bbaa7444b4f853f1bc4fb9)) - -## [1.72.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.72.0...v1.72.1) (2022-05-25) - - -### Bug Fixes - -* Fixed `terraform_fmt` with `tfenv`, when `terraform` default version is not specified ([#389](https://github.com/antonbabenko/pre-commit-terraform/issues/389)) ([1b9476a](https://github.com/antonbabenko/pre-commit-terraform/commit/1b9476a2798f49c474cb59e812ddaf66b2cc6ca2)) - -# [1.72.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.71.0...v1.72.0) (2022-05-25) - - -### Features - -* When a config file is given, do not specify formatter on cli (terraform_docs) ([#386](https://github.com/antonbabenko/pre-commit-terraform/issues/386)) ([962054b](https://github.com/antonbabenko/pre-commit-terraform/commit/962054b923e7a4fff5338fd3f5cb76f957797dd3)) - -# [1.71.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.70.1...v1.71.0) (2022-05-02) - - -### Features - -* Added terraform_wrapper_module_for_each hook ([#376](https://github.com/antonbabenko/pre-commit-terraform/issues/376)) ([e4e9a73](https://github.com/antonbabenko/pre-commit-terraform/commit/e4e9a73d7eb8182bcad5ffca17876d1c0a4a8a49)) - -## [1.70.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.70.0...v1.70.1) (2022-04-28) - - -### Bug Fixes - -* Fixed `tfupdate` to work in all cases, not only `pre-commit run --all` ([#375](https://github.com/antonbabenko/pre-commit-terraform/issues/375)) ([297cc75](https://github.com/antonbabenko/pre-commit-terraform/commit/297cc757879f25bed6d3adf3b6254cf0d37b17c2)) - -# [1.70.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.69.0...v1.70.0) (2022-04-28) - - -### Features - -* Add support for `pre-commit/pre-commit-hooks` in Docker image ([#374](https://github.com/antonbabenko/pre-commit-terraform/issues/374)) ([017da74](https://github.com/antonbabenko/pre-commit-terraform/commit/017da745d0817f94b44c3c773e4aa8d42a80aa09)) - -# [1.69.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.68.1...v1.69.0) (2022-04-26) - - -### Features - -* Allow env vars expansion in `--args` section for all hooks ([#363](https://github.com/antonbabenko/pre-commit-terraform/issues/363)) ([caa01c3](https://github.com/antonbabenko/pre-commit-terraform/commit/caa01c30b33a5a829b75ee6a9e9e08a534a42216)) - -## [1.68.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.68.0...v1.68.1) (2022-04-20) - - -### Bug Fixes - -* Fixed git fatal error in Dockerfile ([#372](https://github.com/antonbabenko/pre-commit-terraform/issues/372)) ([c3f8dd4](https://github.com/antonbabenko/pre-commit-terraform/commit/c3f8dd40e6d6867c661e2495f8194ee7bd9c7fdd)) - -# [1.68.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.67.0...v1.68.0) (2022-04-18) - - -### Features - -* Removed `coreutils` (realpath) from dependencies for MacOS ([#368](https://github.com/antonbabenko/pre-commit-terraform/issues/368)) ([944a2e5](https://github.com/antonbabenko/pre-commit-terraform/commit/944a2e5fefd50df6130c68bcaa4beb4d770c11b9)) - -# [1.67.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.66.0...v1.67.0) (2022-04-15) - - -### Features - -* Added `terraform_checkov` (run per folder), deprecated `checkov` hook ([#290](https://github.com/antonbabenko/pre-commit-terraform/issues/290)) ([e3a9834](https://github.com/antonbabenko/pre-commit-terraform/commit/e3a98345bb3be407c476749496827b418b81241c)) - -# [1.66.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.65.1...v1.66.0) (2022-04-13) - - -### Features - -* Added support for `tfupdate` to update version constraints in Terraform configurations ([#342](https://github.com/antonbabenko/pre-commit-terraform/issues/342)) ([ef7a0f2](https://github.com/antonbabenko/pre-commit-terraform/commit/ef7a0f2b467d20f30341d25df3d4012cff2194ec)) - -## [1.65.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.65.0...v1.65.1) (2022-04-13) - - -### Bug Fixes - -* Improve `tflint --init` command execution ([#361](https://github.com/antonbabenko/pre-commit-terraform/issues/361)) ([d31cb69](https://github.com/antonbabenko/pre-commit-terraform/commit/d31cb6936376bd1aaa9ada83021c29e6ca6727e0)) - -# [1.65.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.64.1...v1.65.0) (2022-04-13) - - -### Features - -* Adding init to terraform_tflint hook ([#352](https://github.com/antonbabenko/pre-commit-terraform/issues/352)) ([1aff30f](https://github.com/antonbabenko/pre-commit-terraform/commit/1aff30f2a4cb0df65a1e693690b5225a112cf621)) - -## [1.64.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.64.0...v1.64.1) (2022-03-31) - - -### Bug Fixes - -* Make hooks bash 3.2 compatible ([#339](https://github.com/antonbabenko/pre-commit-terraform/issues/339)) ([4ad825d](https://github.com/antonbabenko/pre-commit-terraform/commit/4ad825d8d39254c69f0e01fb3e7728f0be9acbb9)) - -# [1.64.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.63.0...v1.64.0) (2022-02-10) - - -### Features - -* Improved speed of `pre-commit run -a` for multiple hooks ([#338](https://github.com/antonbabenko/pre-commit-terraform/issues/338)) ([579dc45](https://github.com/antonbabenko/pre-commit-terraform/commit/579dc45fb40bc64c6742d42a9da78eddb0b70e1d)) - -# [1.63.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.62.3...v1.63.0) (2022-02-10) - - -### Features - -* Improve performance during `pre-commit --all (-a)` run ([#327](https://github.com/antonbabenko/pre-commit-terraform/issues/327)) ([7e7c916](https://github.com/antonbabenko/pre-commit-terraform/commit/7e7c91643e8f213168b95d0583f787f914b04ce4)) - -## [1.62.3](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.62.2...v1.62.3) (2021-12-22) - - -### Bug Fixes - -* Check all directories with changes and pass all args in terrascan hook ([#305](https://github.com/antonbabenko/pre-commit-terraform/issues/305)) ([66401d9](https://github.com/antonbabenko/pre-commit-terraform/commit/66401d93f485164fb2272af297df835b932c61c3)) - -## [1.62.2](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.62.1...v1.62.2) (2021-12-21) - - -### Bug Fixes - -* Properly exclude .terraform directory with checkov hook ([#306](https://github.com/antonbabenko/pre-commit-terraform/issues/306)) ([b431a43](https://github.com/antonbabenko/pre-commit-terraform/commit/b431a43ffa6cd13156485ef853c967856e9572ef)) -* Speedup `terrascan` hook up to x3 times in big repos ([#307](https://github.com/antonbabenko/pre-commit-terraform/issues/307)) ([2e8dcf9](https://github.com/antonbabenko/pre-commit-terraform/commit/2e8dcf9298733a256cc7f8c6f05b3ef9a1047a36)) - -## [1.62.1](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.62.0...v1.62.1) (2021-12-18) - - -### Bug Fixes - -* **terraform_tflint:** Restore current working directory behavior ([#302](https://github.com/antonbabenko/pre-commit-terraform/issues/302)) ([93029dc](https://github.com/antonbabenko/pre-commit-terraform/commit/93029dcfcf6b9b121c24573f3e647d9fde255486)) - -# [1.62.0](https://github.com/antonbabenko/pre-commit-terraform/compare/v1.61.0...v1.62.0) (2021-12-12) - - -### Features - -* Added semantic release ([#296](https://github.com/antonbabenko/pre-commit-terraform/issues/296)) ([1bcca44](https://github.com/antonbabenko/pre-commit-terraform/commit/1bcca44d1677128c23d505be644f1d16c320eb4c)) - -# Change Log - -All notable changes to this project will be documented in this file. - - -## [Unreleased] - - - - -## [v1.61.0] - 2021-12-11 - -- feat: Pass custom arguments to terraform init in `terraform_validate` hook ([#293](https://github.com/antonbabenko/pre-commit-terraform/issues/293)) -- fix: analyse all folders with tflint and don't stop on first execution ([#289](https://github.com/antonbabenko/pre-commit-terraform/issues/289)) - - - -## [v1.60.0] - 2021-12-08 - -- fix: pre-build docker image ([#292](https://github.com/antonbabenko/pre-commit-terraform/issues/292)) - - - -## [v1.59.0] - 2021-12-06 - -- fix: Fixed docker build ([#288](https://github.com/antonbabenko/pre-commit-terraform/issues/288)) - - - -## [v1.58.0] - 2021-11-20 - -- chore: Publish container image on release ([#285](https://github.com/antonbabenko/pre-commit-terraform/issues/285)) -- chore: Fix master merge to working branch on pre-commit autofixes ([#286](https://github.com/antonbabenko/pre-commit-terraform/issues/286)) - - - -## [v1.57.0] - 2021-11-17 - -- fix: typo in arg name for terraform-docs ([#283](https://github.com/antonbabenko/pre-commit-terraform/issues/283)) -- chore: Add deprecation notice to `terraform_docs_replace` ([#280](https://github.com/antonbabenko/pre-commit-terraform/issues/280)) - - - -## [v1.56.0] - 2021-11-08 - -- feat: Updated Docker image from Ubuntu to Alpine ([#278](https://github.com/antonbabenko/pre-commit-terraform/issues/278)) -- chore: Updated messages shown in terraform_tflint hook ([#274](https://github.com/antonbabenko/pre-commit-terraform/issues/274)) - - - -## [v1.55.0] - 2021-10-27 - -- fix: Fixed 1.54.0 where `terraform_docs` was broken ([#272](https://github.com/antonbabenko/pre-commit-terraform/issues/272)) - - - -## [v1.54.0] - 2021-10-27 - -- feat: Add support for quoted values in `infracost_breakdown` `--hook-config` ([#269](https://github.com/antonbabenko/pre-commit-terraform/issues/269)) -- docs: Added notes about sponsors ([#268](https://github.com/antonbabenko/pre-commit-terraform/issues/268)) -- fix: Fixed args expand in terraform_docs ([#260](https://github.com/antonbabenko/pre-commit-terraform/issues/260)) - - - -## [v1.53.0] - 2021-10-26 - -- docs: Pre-release 1.53 ([#267](https://github.com/antonbabenko/pre-commit-terraform/issues/267)) -- docs: Clarify docs for terraform_tfsec hook ([#266](https://github.com/antonbabenko/pre-commit-terraform/issues/266)) -- feat: Add infracost_breakdown hook ([#252](https://github.com/antonbabenko/pre-commit-terraform/issues/252)) -- feat: Set up PR reviewers automatically ([#258](https://github.com/antonbabenko/pre-commit-terraform/issues/258)) -- docs: fix protocol to prevent MITM ([#257](https://github.com/antonbabenko/pre-commit-terraform/issues/257)) -- feat: add __GIT_WORKING_DIR__ to tfsec ([#255](https://github.com/antonbabenko/pre-commit-terraform/issues/255)) -- docs: Add missing space in terrascan install cmd ([#253](https://github.com/antonbabenko/pre-commit-terraform/issues/253)) -- fix: command not found ([#251](https://github.com/antonbabenko/pre-commit-terraform/issues/251)) -- fix: execute tflint once in no errors ([#250](https://github.com/antonbabenko/pre-commit-terraform/issues/250)) -- docs: fix deps ([#249](https://github.com/antonbabenko/pre-commit-terraform/issues/249)) -- feat: Add `terraform_docs` hook settings ([#245](https://github.com/antonbabenko/pre-commit-terraform/issues/245)) -- fix: terrafrom_tflint ERROR output for files located in repo root ([#243](https://github.com/antonbabenko/pre-commit-terraform/issues/243)) -- feat: Add support for specify terraform-docs config file ([#244](https://github.com/antonbabenko/pre-commit-terraform/issues/244)) -- docs: Document hooks dependencies ([#247](https://github.com/antonbabenko/pre-commit-terraform/issues/247)) -- feat: Allow passing of args to terraform_fmt ([#147](https://github.com/antonbabenko/pre-commit-terraform/issues/147)) -- docs: Add terraform_fmt usage instructions and how-to debug script with args ([#242](https://github.com/antonbabenko/pre-commit-terraform/issues/242)) -- fix: TFSec outputs the same results multiple times ([#237](https://github.com/antonbabenko/pre-commit-terraform/issues/237)) -- chore: Do not mark issues and PR's in milestone as stale ([#241](https://github.com/antonbabenko/pre-commit-terraform/issues/241)) - - - -## [v1.52.0] - 2021-10-04 - -- feat: Add new hook for `terraform providers lock` operation ([#173](https://github.com/antonbabenko/pre-commit-terraform/issues/173)) -- docs: Document terraform_tfsec args usage ([#238](https://github.com/antonbabenko/pre-commit-terraform/issues/238)) -- docs: Make contributors more visible ([#236](https://github.com/antonbabenko/pre-commit-terraform/issues/236)) -- docs: Add contributing guide and docs about performance tests ([#235](https://github.com/antonbabenko/pre-commit-terraform/issues/235)) -- fix: terraform_tflint hook executes in a serial way to run less often ([#211](https://github.com/antonbabenko/pre-commit-terraform/issues/211)) -- feat: Add PATH outputs when TFLint found any problem ([#234](https://github.com/antonbabenko/pre-commit-terraform/issues/234)) -- fix: Dockerfile if INSTALL_ALL is not defined ([#233](https://github.com/antonbabenko/pre-commit-terraform/issues/233)) -- docs: Describe hooks usage and improve examples ([#232](https://github.com/antonbabenko/pre-commit-terraform/issues/232)) -- chore: Add shfmt to workflow ([#231](https://github.com/antonbabenko/pre-commit-terraform/issues/231)) -- fix: remove dead code from terraform-docs script ([#229](https://github.com/antonbabenko/pre-commit-terraform/issues/229)) - - - -## [v1.51.0] - 2021-09-17 - -- fix: trigger terraform-docs on changes in lock files ([#228](https://github.com/antonbabenko/pre-commit-terraform/issues/228)) -- fix: label auto-adding after label rename ([#226](https://github.com/antonbabenko/pre-commit-terraform/issues/226)) -- chore: Updated GH stale action config ([#223](https://github.com/antonbabenko/pre-commit-terraform/issues/223)) -- feat: Add GH checks and templates ([#222](https://github.com/antonbabenko/pre-commit-terraform/issues/222)) -- feat: Add mixed line ending check to prevent possible errors ([#221](https://github.com/antonbabenko/pre-commit-terraform/issues/221)) -- fix: Dockerized pre-commit-terraform ([#219](https://github.com/antonbabenko/pre-commit-terraform/issues/219)) -- docs: Initial docs improvement ([#218](https://github.com/antonbabenko/pre-commit-terraform/issues/218)) -- chore: Update Ubuntu install method ([#198](https://github.com/antonbabenko/pre-commit-terraform/issues/198)) - - - -## [v1.50.0] - 2021-04-22 - -- feat: Adds support for Terrascan ([#195](https://github.com/antonbabenko/pre-commit-terraform/issues/195)) - - - -## [v1.49.0] - 2021-04-20 - -- fix: Fix and pin versions in Dockerfile ([#193](https://github.com/antonbabenko/pre-commit-terraform/issues/193)) -- chore: Fix mistake on command ([#185](https://github.com/antonbabenko/pre-commit-terraform/issues/185)) -- Update README.md - - - -## [v1.48.0] - 2021-03-12 - -- chore: add dockerfile ([#183](https://github.com/antonbabenko/pre-commit-terraform/issues/183)) -- docs: Added checkov install ([#182](https://github.com/antonbabenko/pre-commit-terraform/issues/182)) - - - -## [v1.47.0] - 2021-02-25 - -- fix: remove sed postprocessing from the terraform_docs_replace hook to fix compatibility with terraform-docs 0.11.0+ ([#176](https://github.com/antonbabenko/pre-commit-terraform/issues/176)) -- docs: updates installs for macOS and ubuntu ([#175](https://github.com/antonbabenko/pre-commit-terraform/issues/175)) - - - -## [v1.46.0] - 2021-02-20 - -- fix: Terraform validate for submodules ([#172](https://github.com/antonbabenko/pre-commit-terraform/issues/172)) - - - -## [v1.45.0] - 2020-11-12 - -- fix: Correct deprecated parameter to terraform-docs ([#156](https://github.com/antonbabenko/pre-commit-terraform/issues/156)) - - - -## [v1.44.0] - 2020-11-02 - - - - -## [v1.43.1] - 2020-11-02 - -- feat: Make terraform_validate to run init if necessary ([#158](https://github.com/antonbabenko/pre-commit-terraform/issues/158)) - - - -## [v1.43.0] - 2020-09-24 - -- fix: Fix regex considering terraform-docs v0.10.0 old ([#151](https://github.com/antonbabenko/pre-commit-terraform/issues/151)) - - - -## [v1.42.0] - 2020-09-24 - -- fix: make terraform_docs Windows compatible ([#129](https://github.com/antonbabenko/pre-commit-terraform/issues/129)) - - - -## [v1.41.0] - 2020-09-23 - -- fix: terraform-docs version 0.10 removed with-aggregate-type-defaults ([#150](https://github.com/antonbabenko/pre-commit-terraform/issues/150)) - - - -## [v1.40.0] - 2020-09-22 - -- feat: Add possibility to share tflint config file for subdirs ([#149](https://github.com/antonbabenko/pre-commit-terraform/issues/149)) - - - -## [v1.39.0] - 2020-09-08 - -- feat: Add checkov support ([#143](https://github.com/antonbabenko/pre-commit-terraform/issues/143)) - - - -## [v1.38.0] - 2020-09-07 - -- fix: Correctly handle arrays in terraform_docs.sh ([#141](https://github.com/antonbabenko/pre-commit-terraform/issues/141)) - - - -## [v1.37.0] - 2020-09-01 - -- fix: make terraform_tfsec.sh executable ([#140](https://github.com/antonbabenko/pre-commit-terraform/issues/140)) - - - -## [v1.36.0] - 2020-09-01 - -- feat: have option for terraform_tfsec hook to only run in relevant modified directories ([#135](https://github.com/antonbabenko/pre-commit-terraform/issues/135)) - - - -## [v1.35.0] - 2020-08-28 - -- fix: Squash terraform_docs bug ([#138](https://github.com/antonbabenko/pre-commit-terraform/issues/138)) - - - -## [v1.34.0] - 2020-08-27 - -- chore: Use lib_getopt for all hooks and some style tweaks ([#137](https://github.com/antonbabenko/pre-commit-terraform/issues/137)) - - - -## [v1.33.0] - 2020-08-27 - -- fix: Pass args and env vars to terraform validate ([#125](https://github.com/antonbabenko/pre-commit-terraform/issues/125)) -- docs: Update terraform-docs link pointing to new organization ([#130](https://github.com/antonbabenko/pre-commit-terraform/issues/130)) - - - -## [v1.32.0] - 2020-08-19 - -- feat: add terragrunt validate hook ([#134](https://github.com/antonbabenko/pre-commit-terraform/issues/134)) - - - -## [v1.31.0] - 2020-05-27 - -- fix: Updated formatting in README (closes [#113](https://github.com/antonbabenko/pre-commit-terraform/issues/113)) -- docs: Fixed the docs to use the latest config syntax([#106](https://github.com/antonbabenko/pre-commit-terraform/issues/106)) -- docs: Added coreutils as requirements in README.md ([#105](https://github.com/antonbabenko/pre-commit-terraform/issues/105)) - - - -## [v1.30.0] - 2020-04-23 - -- Updated pre-commit deps -- feat: Support for TFSec ([#103](https://github.com/antonbabenko/pre-commit-terraform/issues/103)) - - - -## [v1.29.0] - 2020-04-04 - -- fix: Change terraform_validate hook functionality for subdirectories with terraform files ([#100](https://github.com/antonbabenko/pre-commit-terraform/issues/100)) - -### - -configuration for the appropriate working directory. - -* Neglected to change the terraform validate call to use the default of the -current directory. - -* Several changes to improve functionality: -- Switch to checking the path for '*.tf' instead of always checking the current - -directory. -- Try to find a '.terraform' directory (which indicates a `terraform init`) and - -change to that directory before running `terraform validate`. - -* Fix the description for the terraform_validate hook to reflect changes that were -made in: -https://github.com/antonbabenko/pre-commit-terraform/commit/35e0356188b64a4c5af9a4e7200d936e514cba71 - -* - Clean up comments. -- Adjust variable names to better reflect what they are holding. - - - -## [v1.28.0] - 2020-04-04 - -- Allow passing multiple args to terraform-docs ([#98](https://github.com/antonbabenko/pre-commit-terraform/issues/98)) -- Update installation instructions ([#79](https://github.com/antonbabenko/pre-commit-terraform/issues/79)) - - - -## [v1.27.0] - 2020-03-02 - -- corrected tflint documentation ([#95](https://github.com/antonbabenko/pre-commit-terraform/issues/95)) - - - -## [v1.26.0] - 2020-02-21 - -- Updated pre-commit-hooks -- Fixed exit code for terraform 0.11 branch in terraform_docs ([#94](https://github.com/antonbabenko/pre-commit-terraform/issues/94)) - - - -## [v1.25.0] - 2020-01-30 - -- Fixed tflint hook to iterate over files ([#77](https://github.com/antonbabenko/pre-commit-terraform/issues/77)) - - - -## [v1.24.0] - 2020-01-21 - -- Added shfmt to autoformat shell scripts ([#86](https://github.com/antonbabenko/pre-commit-terraform/issues/86)) - - - -## [v1.23.0] - 2020-01-21 - -- Added support for terraform-docs 0.8.0 with proper support for Terraform 0.12 syntax (bye-bye awk) ([#85](https://github.com/antonbabenko/pre-commit-terraform/issues/85)) - - - -## [v1.22.0] - 2020-01-13 - -- move terraform-docs args after markdown command ([#83](https://github.com/antonbabenko/pre-commit-terraform/issues/83)) - - - -## [v1.21.0] - 2019-11-16 - -- use getopt for args in the tflint hook, following the approach in terraform-docs ([#75](https://github.com/antonbabenko/pre-commit-terraform/issues/75)) - - - -## [v1.20.0] - 2019-11-02 - -- Fixes [#65](https://github.com/antonbabenko/pre-commit-terraform/issues/65): terraform-docs should not fail if complex types contain 'description' keyword ([#73](https://github.com/antonbabenko/pre-commit-terraform/issues/73)) -- Added FUNDING.yml -- Improve installation instructions and make README more readable ([#72](https://github.com/antonbabenko/pre-commit-terraform/issues/72)) -- Update rev in README.md ([#70](https://github.com/antonbabenko/pre-commit-terraform/issues/70)) - - - -## [v1.19.0] - 2019-08-20 - -- Updated README with terraform_tflint hook -- Added support for TFLint with --deep parameter ([#53](https://github.com/antonbabenko/pre-commit-terraform/issues/53)) - - - -## [v1.18.0] - 2019-08-20 - -- Updated README with terragrunt_fmt hook -- Formatter for Terragrunt HCL files ([#60](https://github.com/antonbabenko/pre-commit-terraform/issues/60)) - - - -## [v1.17.0] - 2019-06-25 - -- Fixed enquoted types in terraform_docs (fixed [#52](https://github.com/antonbabenko/pre-commit-terraform/issues/52)) -- Fix typo in README ([#51](https://github.com/antonbabenko/pre-commit-terraform/issues/51)) - - - -## [v1.16.0] - 2019-06-18 - -- Add slash to mktemp dir (fixed [#50](https://github.com/antonbabenko/pre-commit-terraform/issues/50)) - - - -## [v1.15.0] - 2019-06-18 - -- Fixed awk script for terraform-docs (kudos [@cytopia](https://github.com/cytopia)) and mktemp on Mac (closes [#47](https://github.com/antonbabenko/pre-commit-terraform/issues/47), [#48](https://github.com/antonbabenko/pre-commit-terraform/issues/48), [#49](https://github.com/antonbabenko/pre-commit-terraform/issues/49)) -- Fix version in README.md ([#46](https://github.com/antonbabenko/pre-commit-terraform/issues/46)) - - - -## [v1.14.0] - 2019-06-17 - -- Upgraded to work with Terraform >= 0.12 ([#44](https://github.com/antonbabenko/pre-commit-terraform/issues/44)) - - - -## [v1.13.0] - 2019-06-17 - -- Added support for terraform_docs for Terraform 0.12 ([#45](https://github.com/antonbabenko/pre-commit-terraform/issues/45)) - - - -## [v1.12.0] - 2019-05-27 - -- Added note about incompatibility of terraform-docs with Terraform 0.12 ([#41](https://github.com/antonbabenko/pre-commit-terraform/issues/41)) -- Fixed broken "maintained badge" -- Update README.md ([#36](https://github.com/antonbabenko/pre-commit-terraform/issues/36)) - - - -## [v1.11.0] - 2019-03-01 - -- Updated changelog -- fix check for errors at the end ([#35](https://github.com/antonbabenko/pre-commit-terraform/issues/35)) - - - -## [v1.10.0] - 2019-02-21 - -- Bump new version -- Add exit code for 'terraform validate' so pre-commit check fails ([#34](https://github.com/antonbabenko/pre-commit-terraform/issues/34)) - - - -## [v1.9.0] - 2019-02-18 - -- Added chglog (hi [@robinbowes](https://github.com/robinbowes) :)) -- Require terraform-docs runs in serial to avoid pre-commit doing parallel operations on similar file paths - - - -## [v1.8.1] - 2018-12-15 - -- Fix bug not letting terraform_docs_replace work in the root directory of a repo - - - -## [v1.8.0] - 2018-12-14 - -- fix typo -- Address requested changes -- Add `--dest` argument -- Address requested changes -- Add new hook for running terraform-docs with replacing README.md from doc in main.tf - - - -## [v1.7.4] - 2018-12-11 - -- Merge remote-tracking branch 'origin/master' into pr25 -- Added followup after [#25](https://github.com/antonbabenko/pre-commit-terraform/issues/25) -- Add feature to pass options to terraform-docs. -- Added license file (fixed [#21](https://github.com/antonbabenko/pre-commit-terraform/issues/21)) - - - -## [v1.7.3] - 2018-05-24 - -- Updated README -- Only run validate if .tf files exist in the directory. ([#20](https://github.com/antonbabenko/pre-commit-terraform/issues/20)) - - - -## [v1.7.2] - 2018-05-20 - -- Replace terraform_docs use of GNU sed with perl ([#15](https://github.com/antonbabenko/pre-commit-terraform/issues/15)) -- Fixes use of md5 for tempfile name ([#16](https://github.com/antonbabenko/pre-commit-terraform/issues/16)) - - - -## [v1.7.1] - 2018-05-16 - -- Run terraform_docs only if README.md is present -- Run terraform_docs only if README.md is present - - - -## [v1.7.0] - 2018-05-16 - -- Added terraform-docs integration ([#13](https://github.com/antonbabenko/pre-commit-terraform/issues/13)) - - - -## [v1.6.0] - 2018-04-21 - -- Allow to have spaces in directories ([#11](https://github.com/antonbabenko/pre-commit-terraform/issues/11)) - - - -## [v1.5.0] - 2018-03-06 - -- Bump new version -- Format tfvars files explicitely, because terraform fmt ignores them ([#9](https://github.com/antonbabenko/pre-commit-terraform/issues/9)) - - - -## [v1.4.0] - 2018-01-24 - -- Updated readme -- Show failed path -- Show failed path -- Show failed path -- Updated scripts -- Added scripts to validate terraform files - - - -## [v1.3.0] - 2018-01-15 - -- Added badges -- Added formatting for tfvars (fixes [#4](https://github.com/antonbabenko/pre-commit-terraform/issues/4)) ([#6](https://github.com/antonbabenko/pre-commit-terraform/issues/6)) - - - -## [v1.2.0] - 2017-06-08 - -- Renamed shell script file to the correct one -- Updated .pre-commit-hooks.yaml -- Updated sha in README -- Exclude .terraform even on subfolders - - - -## [v1.1.0] - 2017-02-04 - -- Copied to .pre-commit-hooks.yaml for compatibility (closes [#1](https://github.com/antonbabenko/pre-commit-terraform/issues/1)) - - - -## v1.0.0 - 2016-09-27 - -- Updated README -- Ready, probably :) -- Initial commit -- Initial commit - - -[Unreleased]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.61.0...HEAD -[v1.61.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.60.0...v1.61.0 -[v1.60.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.59.0...v1.60.0 -[v1.59.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.58.0...v1.59.0 -[v1.58.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.57.0...v1.58.0 -[v1.57.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.56.0...v1.57.0 -[v1.56.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.55.0...v1.56.0 -[v1.55.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.54.0...v1.55.0 -[v1.54.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.53.0...v1.54.0 -[v1.53.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.52.0...v1.53.0 -[v1.52.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.51.0...v1.52.0 -[v1.51.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.50.0...v1.51.0 -[v1.50.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.49.0...v1.50.0 -[v1.49.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.48.0...v1.49.0 -[v1.48.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.47.0...v1.48.0 -[v1.47.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.46.0...v1.47.0 -[v1.46.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.45.0...v1.46.0 -[v1.45.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.44.0...v1.45.0 -[v1.44.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.43.1...v1.44.0 -[v1.43.1]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.43.0...v1.43.1 -[v1.43.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.42.0...v1.43.0 -[v1.42.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.41.0...v1.42.0 -[v1.41.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.40.0...v1.41.0 -[v1.40.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.39.0...v1.40.0 -[v1.39.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.38.0...v1.39.0 -[v1.38.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.37.0...v1.38.0 -[v1.37.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.36.0...v1.37.0 -[v1.36.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.35.0...v1.36.0 -[v1.35.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.34.0...v1.35.0 -[v1.34.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.33.0...v1.34.0 -[v1.33.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.32.0...v1.33.0 -[v1.32.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.31.0...v1.32.0 -[v1.31.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.30.0...v1.31.0 -[v1.30.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.29.0...v1.30.0 -[v1.29.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.28.0...v1.29.0 -[v1.28.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.27.0...v1.28.0 -[v1.27.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.26.0...v1.27.0 -[v1.26.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.25.0...v1.26.0 -[v1.25.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.24.0...v1.25.0 -[v1.24.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.23.0...v1.24.0 -[v1.23.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.22.0...v1.23.0 -[v1.22.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.21.0...v1.22.0 -[v1.21.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.20.0...v1.21.0 -[v1.20.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.19.0...v1.20.0 -[v1.19.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.18.0...v1.19.0 -[v1.18.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.17.0...v1.18.0 -[v1.17.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.16.0...v1.17.0 -[v1.16.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.15.0...v1.16.0 -[v1.15.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.14.0...v1.15.0 -[v1.14.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.13.0...v1.14.0 -[v1.13.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.12.0...v1.13.0 -[v1.12.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.11.0...v1.12.0 -[v1.11.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.10.0...v1.11.0 -[v1.10.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.9.0...v1.10.0 -[v1.9.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.8.1...v1.9.0 -[v1.8.1]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.8.0...v1.8.1 -[v1.8.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.7.4...v1.8.0 -[v1.7.4]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.7.3...v1.7.4 -[v1.7.3]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.7.2...v1.7.3 -[v1.7.2]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.7.1...v1.7.2 -[v1.7.1]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.7.0...v1.7.1 -[v1.7.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.6.0...v1.7.0 -[v1.6.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.5.0...v1.6.0 -[v1.5.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.4.0...v1.5.0 -[v1.4.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.3.0...v1.4.0 -[v1.3.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.2.0...v1.3.0 -[v1.2.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.1.0...v1.2.0 -[v1.1.0]: https://github.com/antonbabenko/pre-commit-terraform/compare/v1.0.0...v1.1.0 +* TODO \ No newline at end of file diff --git a/LICENSE b/LICENSE index 2755ae9..5822c23 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ Copyright (c) 2017 Anton Babenko +Copyright (c) 2024 ttofuutils authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index 7126a24..fef92f9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Want to contribute? Check [open issues](https://github.com/tofuutils/pre-commit-opentofu/issues?q=label%3A%22good+first+issue%22+is%3Aopen+sort%3Aupdated-desc) and [contributing notes](/.github/CONTRIBUTING.md). ## Sponsors -If you are using `pre-commit-terraform` already or want to support its development and [many other open-source projects](https://github.com/antonbabenko/terraform-aws-devops), please become a [GitHub Sponsor](https://github.com/sponsors/antonbabenko)! +If you are using `pre-commit-terraform` already or want to support its development and [many other open-source projects](https://github.com/tofuutils), please become a [GitHub Sponsor](https://github.com/sponsors/tofuutils)! ## Table of content @@ -1026,7 +1026,7 @@ docker run --rm -e "USERID=$(id -u):$(id -g)" -v ~/.netrc:/root/.netrc -v $(pwd) ## Authors -This repository is managed by [Anton Babenko](https://github.com/antonbabenko) with help from these awesome contributors: +This repository is managed by [Alexander Sharov](https://github.com/kvendingoldo), [Nikolay Mishin](https://github.com/Nmishin), and [Anastasiia Kozlova](https://github.com/anastasiiakozlova245) with help from these awesome contributors: @@ -1047,9 +1047,3 @@ This repository is managed by [Anton Babenko](https://github.com/antonbabenko) w ## License MIT licensed. See [LICENSE](LICENSE) for full details. - -### Additional information for users from Russia and Belarus - -* Russia has [illegally annexed Crimea in 2014](https://en.wikipedia.org/wiki/Annexation_of_Crimea_by_the_Russian_Federation) and [brought the war in Donbas](https://en.wikipedia.org/wiki/War_in_Donbas) followed by [full-scale invasion of Ukraine in 2022](https://en.wikipedia.org/wiki/2022_Russian_invasion_of_Ukraine). -* Russia has brought sorrow and devastations to millions of Ukrainians, killed hundreds of innocent people, damaged thousands of buildings, and forced several million people to flee. -* [Putin khuylo!](https://en.wikipedia.org/wiki/Putin_khuylo!) diff --git a/hooks/__init__.py b/hooks/__init__.py index aeb6f9b..949d238 100644 --- a/hooks/__init__.py +++ b/hooks/__init__.py @@ -1,4 +1,4 @@ print( '`terraform_docs_replace` hook is DEPRECATED.' - 'For migration instructions see https://github.com/antonbabenko/pre-commit-terraform/issues/248#issuecomment-1290829226' + 'For migration instructions see https://github.com/tofuutils/pre-commit-opentofu/issues/248#issuecomment-1290829226' ) diff --git a/hooks/_common.sh b/hooks/_common.sh index 31be981..26246e1 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -135,7 +135,7 @@ function common::parse_and_export_env_vars { ####################################################################### # This is a workaround to improve performance when all files are passed -# See: https://github.com/antonbabenko/pre-commit-terraform/issues/309 +# See: https://github.com/tofuutils/pre-commit-opentofu/issues/309 # Arguments: # hook_id (string) hook ID, see `- id` for details in .pre-commit-hooks.yaml file # files (array) filenames to check diff --git a/hooks/terraform_providers_lock.sh b/hooks/terraform_providers_lock.sh index d85a794..c2b09fc 100755 --- a/hooks/terraform_providers_lock.sh +++ b/hooks/terraform_providers_lock.sh @@ -134,7 +134,7 @@ function per_dir_hook_unique_part { # TODO: Remove in 2.0 if [ ! "$mode" ]; then common::colorify "yellow" "DEPRECATION NOTICE: We introduced '--mode' flag for this hook. -Check migration instructions at https://github.com/antonbabenko/pre-commit-terraform#terraform_providers_lock +Check migration instructions at https://github.com/tofuutils/pre-commit-opentofu#terraform_providers_lock " common::terraform_init 'terraform providers lock' "$dir_path" || { exit_code=$? diff --git a/hooks/terraform_tfsec.sh b/hooks/terraform_tfsec.sh index d05ed42..3ae742c 100755 --- a/hooks/terraform_tfsec.sh +++ b/hooks/terraform_tfsec.sh @@ -23,7 +23,7 @@ function main { fi common::colorify "yellow" "tfsec tool was deprecated, and replaced by trivy. You can check trivy hook here:" - common::colorify "yellow" "https://github.com/antonbabenko/pre-commit-terraform/tree/master#terraform_trivy" + common::colorify "yellow" "https://github.com/tofuutils/pre-commit-opentofu/tree/master#terraform_trivy" common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" } diff --git a/tools/entrypoint.sh b/tools/entrypoint.sh index 86d5e36..b2274d1 100755 --- a/tools/entrypoint.sh +++ b/tools/entrypoint.sh @@ -15,7 +15,7 @@ function echo_error_and_exit { if [[ $(id -u) -ne 0 ]]; then echo_error_and_exit "Container must run as root. Use environment variable USERID to set user.\n" \ "Example: \"TAG=latest && " \ - "docker run -e USERID=$(id -u):$(id -g) -v $(pwd):/lint -w /lint ghcr.io/antonbabenko/pre-commit-terraform:$TAG run -a\"" + "docker run -e USERID=$(id -u):$(id -g) -v $(pwd):/lint -w /lint ghcr.io/tofuutils/pre-commit-opentofu:$TAG run -a\"" fi # make sure USERID makes sense as UID:GID From 233f6c6c8b044bb12b0102b16e148ec4cc0518b8 Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 00:44:43 +0100 Subject: [PATCH 03/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt III --- .github/CONTRIBUTING.md | 16 +++--- .github/ISSUE_TEMPLATE/bug_report_docker.md | 2 +- .../bug_report_local_install.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 6 +-- .github/PULL_REQUEST_TEMPLATE.md | 4 +- .pre-commit-hooks.yaml | 48 +++++++++--------- README.md | 20 ++++---- assets/env0.png | Bin 10210 -> 0 bytes assets/infracost.png | Bin 7258 -> 0 bytes hooks/_common.sh | 18 +++---- hooks/terraform_docs.sh | 4 +- hooks/terraform_fmt.sh | 4 +- hooks/terraform_providers_lock.sh | 8 +-- hooks/terraform_validate.sh | 34 ++++++------- hooks/terraform_wrapper_module_for_each.sh | 28 +++++----- hooks/terrascan.sh | 4 +- tests/Dockerfile | 2 +- tests/hooks_performance_test.sh | 6 +-- 18 files changed, 103 insertions(+), 103 deletions(-) delete mode 100644 assets/env0.png delete mode 100644 assets/infracost.png diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index d72b0a3..864893c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -21,14 +21,14 @@ Enjoy the clean, valid, and documented code! ## Run and debug hooks locally ```bash -pre-commit try-repo {-a} /path/to/local/pre-commit-terraform/repo {hook_name} +pre-commit try-repo {-a} /path/to/local/pre-commit-opentofu/repo {hook_name} ``` I.e. ```bash -pre-commit try-repo /mnt/c/Users/tf/pre-commit-terraform terraform_fmt # Run only `terraform_fmt` check -pre-commit try-repo -a ~/pre-commit-terraform # run all existing checks from repo +pre-commit try-repo /mnt/c/Users/tf/pre-commit-opentofu terraform_fmt # Run only `terraform_fmt` check +pre-commit try-repo -a ~/pre-commit-opentofu # run all existing checks from repo ``` Running `pre-commit` with `try-repo` ignores all arguments specified in `.pre-commit-config.yaml`. @@ -38,7 +38,7 @@ If you need to test hook with arguments, follow [pre-commit doc](https://pre-com For example, to test that the [`terraform_fmt`](../README.md#terraform_fmt) hook works fine with arguments: ```bash -/tmp/pre-commit-terraform/terraform_fmt.sh --args=-diff --args=-write=false test-dir/main.tf test-dir/vars.tf +/tmp/pre-commit-opentofu/terraform_fmt.sh --args=-diff --args=-write=false test-dir/main.tf test-dir/vars.tf ``` ## Run hook performance test @@ -50,7 +50,7 @@ Script accept next options: | # | Name | Example value | Description | | --- | ---------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------- | | 1 | `TEST_NUM` | `200` | How many times need repeat test | -| 2 | `TEST_COMMAND` | `'pre-commit try-repo -a /tmp/159/pre-commit-terraform terraform_tfsec'` | Valid pre-commit command | +| 2 | `TEST_COMMAND` | `'pre-commit try-repo -a /tmp/159/pre-commit-opentofu terraform_tfsec'` | Valid pre-commit command | | 3 | `TEST_DIR` | `'/tmp/infrastructure'` | Dir on what you run tests. | | 4 | `TEST_DESCRIPTION` | ```'`terraform_tfsec` PR #123:'``` | Text that you'd like to see in result | | 5 | `RAW_TEST_`
`RESULTS_FILE_NAME` | `terraform_tfsec_pr123` | (Temporary) File where all test data will be stored. | @@ -66,14 +66,14 @@ Script accept next options: # Install deps sudo apt install -y datamash # Run tests -./hooks_performance_test.sh 200 'pre-commit try-repo -a /tmp/159/pre-commit-terraform terraform_tfsec' '/tmp/infrastructure' '`terraform_tfsec` v1.51.0:' 'terraform_tfsec_pr159' +./hooks_performance_test.sh 200 'pre-commit try-repo -a /tmp/159/pre-commit-opentofu terraform_tfsec' '/tmp/infrastructure' '`terraform_tfsec` v1.51.0:' 'terraform_tfsec_pr159' ``` ### Run via Docker ```bash -# Build `pre-commit-terraform` image -docker build -t pre-commit-terraform --build-arg INSTALL_ALL=true . +# Build `pre-commit-opentofu` image +docker build -t pre-commit-opentofu --build-arg INSTALL_ALL=true . # Build test image docker build -t pre-commit-tests tests/ # Run diff --git a/.github/ISSUE_TEMPLATE/bug_report_docker.md b/.github/ISSUE_TEMPLATE/bug_report_docker.md index a47e306..f0bf43a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_docker.md +++ b/.github/ISSUE_TEMPLATE/bug_report_docker.md @@ -7,7 +7,7 @@ labels: --- -### How could pre-commit-terraform help solve your problem? +### How could pre-commit-opentofu help solve your problem? diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 1f3b564..9d01233 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,5 +1,5 @@ Put an `x` into the box if that apply: @@ -15,7 +15,7 @@ Put an `x` into the box if that apply: Briefly describe what this pull request does. Be sure to direct your reviewers' attention to anything that needs special consideration. -We love pull requests that resolve an open pre-commit-terraform issue. If yours does, you +We love pull requests that resolve an open pre-commit-opentofu issue. If yours does, you can uncomment the below line to indicate which issue your PR fixes, for example "Fixes #123456": --> diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index e8115b4..a028149 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -1,16 +1,16 @@ - id: infracost_breakdown name: Infracost breakdown - description: Check terraform infrastructure cost + description: Check OpenTofu infrastructure cost entry: hooks/infracost_breakdown.sh language: script require_serial: true files: \.(tf(vars)?|hcl)$ exclude: \.terraform\/.*$ -- id: terraform_fmt - name: Terraform fmt - description: Rewrites all Terraform configuration files to a canonical format. - entry: hooks/terraform_fmt.sh +- id: tofu_fmt + name: OpenTofu fmt + description: Rewrites all OpenTofu configuration files to a canonical format. + entry: hooks/tofu_fmt.sh language: script files: (\.tf|\.tfvars)$ exclude: \.terraform\/.*$ @@ -42,27 +42,27 @@ files: (\.tf)$ exclude: \.terraform\/.*$ -- id: terraform_validate - name: Terraform validate - description: Validates all Terraform configuration files. +- id: tofu_validate + name: OpenTofu validate + description: Validates all OpenTofu configuration files. require_serial: true - entry: hooks/terraform_validate.sh + entry: hooks/tofu_validate.sh language: script files: (\.tf|\.tfvars)$ exclude: \.terraform\/.*$ - id: terraform_providers_lock - name: Lock terraform provider versions + name: Lock OpenTofu provider versions description: Updates provider signatures in dependency lock files. require_serial: true - entry: hooks/terraform_providers_lock.sh + entry: hooks/tofu_providers_lock.sh language: script files: (\.terraform\.lock\.hcl)$ exclude: \.terraform\/.*$ - id: terraform_tflint - name: Terraform validate with tflint - description: Validates all Terraform configuration files with TFLint. + name: OpenTofu validate with tflint + description: Validates all OpenTofu configuration files with TFLint. require_serial: true entry: hooks/terraform_tflint.sh language: script @@ -86,16 +86,16 @@ exclude: \.terraform\/.*$ - id: terraform_tfsec - name: Terraform validate with tfsec (deprecated, use "terraform_trivy") - description: Static analysis of Terraform templates to spot potential security issues. + name: OpenTofu validate with tfsec (deprecated, use "terraform_trivy") + description: Static analysis of OpenTofu templates to spot potential security issues. require_serial: true entry: hooks/terraform_tfsec.sh files: \.tf(vars)?$ language: script - id: terraform_trivy - name: Terraform validate with trivy - description: Static analysis of Terraform templates to spot potential security issues. + name: OpenTofu validate with trivy + description: Static analysis of OpenTofu templates to spot potential security issues. require_serial: true entry: hooks/terraform_trivy.sh files: \.tf(vars)?$ @@ -103,7 +103,7 @@ - id: checkov name: checkov (deprecated, use "terraform_checkov") - description: Runs checkov on Terraform templates. + description: Runs checkov on OpenTofu templates. entry: checkov -d . language: python pass_filenames: false @@ -112,10 +112,10 @@ exclude: \.terraform\/.*$ require_serial: true -- id: terraform_checkov +- id: tofu_checkov name: Checkov - description: Runs checkov on Terraform templates. - entry: hooks/terraform_checkov.sh + description: Runs checkov on OpenTofu templates. + entry: hooks/tofu_checkov.sh language: script always_run: false files: \.tf$ @@ -124,7 +124,7 @@ - id: terraform_wrapper_module_for_each name: Terraform wrapper with for_each in module - description: Generate Terraform wrappers with for_each in module. + description: Generate OpenTofu wrappers with for_each in module. entry: hooks/terraform_wrapper_module_for_each.sh language: script pass_filenames: false @@ -135,7 +135,7 @@ - id: terrascan name: terrascan - description: Runs terrascan on Terraform templates. + description: Runs terrascan on OpenTofu templates. language: script entry: hooks/terrascan.sh files: \.tf$ @@ -144,7 +144,7 @@ - id: tfupdate name: tfupdate - description: Runs tfupdate on Terraform templates. + description: Runs tfupdate on OpenTofu templates. language: script entry: hooks/tfupdate.sh args: diff --git a/README.md b/README.md index fef92f9..a5daa97 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Want to contribute? Check [open issues](https://github.com/tofuutils/pre-commit-opentofu/issues?q=label%3A%22good+first+issue%22+is%3Aopen+sort%3Aupdated-desc) and [contributing notes](/.github/CONTRIBUTING.md). ## Sponsors -If you are using `pre-commit-terraform` already or want to support its development and [many other open-source projects](https://github.com/tofuutils), please become a [GitHub Sponsor](https://github.com/sponsors/tofuutils)! +If you are using `pre-commit-opentofu` already or want to support its development and [many other open-source projects](https://github.com/tofuutils), please become a [GitHub Sponsor](https://github.com/sponsors/tofuutils)! ## Table of content @@ -92,15 +92,15 @@ When hooks-related `--build-arg`s are not specified, only the latest version of ```bash git clone git@github.com:tofuutils/pre-commit-opentofu.git -cd pre-commit-terraform +cd pre-commit-opentofu # Install the latest versions of all the tools -docker build -t pre-commit-terraform --build-arg INSTALL_ALL=true . +docker build -t pre-commit-opentofu --build-arg INSTALL_ALL=true . ``` To install a specific version of individual tools, define it using `--build-arg` arguments or set it to `latest`: ```bash -docker build -t pre-commit-terraform \ +docker build -t pre-commit-opentofu \ --build-arg PRE_COMMIT_VERSION=latest \ --build-arg TERRAFORM_VERSION=latest \ --build-arg CHECKOV_VERSION=2.0.405 \ @@ -456,9 +456,9 @@ Unlike most other hooks, this hook triggers once if there are any changed files 1. `terraform_docs` and `terraform_docs_without_aggregate_type_defaults` will insert/update documentation generated by [terraform-docs](https://github.com/terraform-docs/terraform-docs) framed by markers: ```txt - + - + ``` if they are present in `README.md`. @@ -473,8 +473,8 @@ Unlike most other hooks, this hook triggers once if there are any changed files To migrate to `terraform-docs` insertion markers, run in repo root: ```bash - grep -rl 'BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK' . | xargs sed -i 's/BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK/BEGIN_TF_DOCS/g' - grep -rl 'END OF PRE-COMMIT-TERRAFORM DOCS HOOK' . | xargs sed -i 's/END OF PRE-COMMIT-TERRAFORM DOCS HOOK/END_TF_DOCS/g' + grep -rl 'BEGINNING OF PRE-COMMIT-OPENTOFU DOCS HOOK' . | xargs sed -i 's/BEGINNING OF PRE-COMMIT-OPENTOFU DOCS HOOK/BEGIN_TF_DOCS/g' + grep -rl 'END OF PRE-COMMIT-OPENTOFU DOCS HOOK' . | xargs sed -i 's/END OF PRE-COMMIT-OPENTOFU DOCS HOOK/END_TF_DOCS/g' ``` ```yaml @@ -669,7 +669,7 @@ To replicate functionality in `terraform_docs` hook: - --args=--config=__GIT_WORKING_DIR__/.tflint.hcl ``` -3. By default, pre-commit-terraform performs directory switching into the terraform 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 terraform 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: ```yaml - id: terraform_tflint @@ -1018,7 +1018,7 @@ machine github.com Finally, you can execute `docker run` with an additional volume mount so that the `~/.netrc` is accessible within the container ```bash -# run pre-commit-terraform with docker +# run pre-commit-opentofu with docker # adding volume for .netrc file # .netrc needs to be in /root/ dir docker run --rm -e "USERID=$(id -u):$(id -g)" -v ~/.netrc:/root/.netrc -v $(pwd):/lint -w /lint ghcr.io/tofuutils/pre-commit-opentofu:latest run -a diff --git a/assets/env0.png b/assets/env0.png deleted file mode 100644 index da3eec1e38f1722e8a82d972f4b26d7c9b21194d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 10210 zcmV<8Cmq;{P)_Fv9sc3X@6~%XQDqfX1z4a2mmr`diV(oYZrdcvQXr;7l9d?H45nkuB5_DG zYHUMR(y_&eLedIJG*Drd$$=qifCdGDs)8!&Rn>b{Z}`VMoU?oFbMO8C`w#EcD@2=K zi(Tv1`|ohhJ;Ofx?D^7P{yBfiFfL`nfk*)jhf#N7kE#nSc)($wvA+b=Jcg?P#|3D1QECPL>0PNKb{P)s2d}3fDGWdp>#^2!a zb6%;2u8cKKZ0KTCH{ShYYUqzkdie1_Esj7DjtcI+yNdU`=Q*rd-1Nj5CVZvj=$k=@=s;gs*&MHCC@Kw4Q(Z=>Ttg+itinp-|{p6BD#Q+@2--NeqFO%#ir<&!cFe7}fhvkqev)~_EyrD9O6HZVL~uys_c zRn+Ts`)v37+jWs`qddaB-3Ae$wX`ewy%Z$juzl0xlR^(sHZ2hoRMMwv~3=Y@ZP*y~p-n9x1YO25Yrip4DI!w2w(| z3_k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inzz^M zu^Jd~T3cm?;4efeAuW+lFg*F>+`7jen@93Vg=8TWi%0Zj?zh?exX`!042i{X(r;#x z`y{&M_x9XGA`G5&*5EBCom85Zi1JJ)od>CZ!v-IxoKnUOH_TbRcfV)SasD}_=q_fQ zk#EBi&CiwR*2hX)3HF&Ggd~nj*KFQA{41|~WlFJ&Wkl6RVq%dH7jD`26GAD(0Kc|s|Y`?RTbXun_Noo4sR=l9Czu10p z0(JY8V$3HnKx%X z8yN`8as2Uxe-dk9h?LgWUSlgYR`!$`oI0mGld)5c|rhp!z=Jt-+KVVBU6~y9>q?YrC)?8t>8=z z(70Q`r{|0WF{T-B(hyWioKzlm9QAc1Z?_O|uY;5KOmCE5OD-}BA$;2f+8eO~AfBdeyqU-Oych(~JQjoAga7~l07*qoM6N<$g3TJ(F#rGn diff --git a/assets/infracost.png b/assets/infracost.png deleted file mode 100644 index bacbd04705e81b9e75edf46831cdae97e1f91632..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7258 zcmbVR2RK{r_ZOS0)l$?5qN-{{6p7k1R@G{?Rz!k|1hJJ;RMl#%QmZXhwf9~{Q6rkF zS*x@{?V6?PpMKZ#`~RQ+zEAGG?|t9T8K3i>bCM@F+SEkvG&3JF6&2NKxW2X-<=#s< zFEG+mu3_9CF_asVhrTtQib`1N_X*HR1v^kt(E(j8ZhGG|Hi98>?$QV+oFhuw-`#_P zrlPv4=I?<(x}m&*jwokWtcu7+Q=16T)k#I<#uZ~(V-GEqi>rR17s@=)!~z-UhJ-qa zsHp<4`oky++)>^Lpual?i--BEi2R`!Mj8K}mJtE|0r7TI5z+W<5O~wr6sU#sLIJNx zD@Y;1@>hV0P-(CNL>>yg43v`vE6KFd2V@hYVO+_BW+JfKJGNa2`Hhm_Lj= zA!Se)lsgLRji+G2|6n~_aNan)3+}&A{m=5hGe8NgvGG4P{!?Gv-TyIx_tx>H(D*AL z|0x=85#WK6F+<^TK3+(ajxWVc(cf%5U|L=%gg4I10*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)Nh z4`X=^KYVnli}O`}oc|tsyN%b`H>mHXP?i+^%^1GSVda)FvY0g9#6I~TN^s#*WJDpU zTB{cne2u2e!-`#q(wr+VRC!THgWD*$)pC>p+S4RsjB5|uUQUl1;zz`j^z}kRaNTTSBXedBc8N<{ z?N}8@Sk53uc;G-Qp=S>;Bvn&$+GesUOw2-+e_!A933ts4oBI~c)?DGXI`LLex>lPH zALm2-3J20srtkD@8=PeE9@nf?)h$*4d`m`VU+T5ky7l1uv5!8q(5OsiBqz=qzC>Jm@5#9)kCGP<-8%LW?SJ^mt^a&J zR^}K7Xp1m#*ziM9`_$!hU3>Yc?epk7B8%e)N}~MqbKL$^xn|#IP_GyR@aDrzzg|YM z8SQDd4MV5hx--IhKCaMcao$jNK5@*qL}z}p`N%kLfKk>FRn2EdeH*|J_+Qw(HAm~v z-229K@4Nlwi8{Aq;zX)W-P&wnRyS5p%5cnJuWI^N&&{dW;FDmY0 zw@SK%mecgf96KH7)iwY2=X6KbkA+E}RhVq^Fuhvt8q5gJ(P1aiN*^B~MdW)uOO+Ao4N_RYHkJvodE6O`rDcWTC`|qmGJn%yfwG(7& zFnxiA+=b-=L{01rF`JEnUby#`#7DzBj$aSsGJSgy{Id5{-4xw_6?q?-e3oHIDs|kw zY-Lu%d?ltM$TB{LU0Z#$n=mgaHfP<0N`8y?`zoky-&1) + init_output=$(tofu init -backend=false "${TF_INIT_ARGS[@]}" 2>&1) exit_code=$? if [ $exit_code -ne 0 ]; then - common::colorify "red" "'terraform init' failed, '$command_name' skipped: $dir_path" + common::colorify "red" "'tofu init' failed, '$command_name' skipped: $dir_path" echo -e "$init_output\n\n" else - common::colorify "green" "Command 'terraform init' successfully done: $dir_path" + common::colorify "green" "Command 'tofu init' successfully done: $dir_path" fi fi diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index c597730..9be2808 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -9,8 +9,8 @@ readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # set up default insertion markers. These will be changed to the markers used by # terraform-docs if the hook config contains `--use-standard-markers=true` -insertion_marker_begin="" -insertion_marker_end="" +insertion_marker_begin="" +insertion_marker_end="" # these are the standard insertion markers used by terraform-docs readonly standard_insertion_marker_begin="" diff --git a/hooks/terraform_fmt.sh b/hooks/terraform_fmt.sh index bb0b327..3d6da88 100755 --- a/hooks/terraform_fmt.sh +++ b/hooks/terraform_fmt.sh @@ -13,7 +13,7 @@ function main { common::export_provided_env_vars "${ENV_VARS[@]}" common::parse_and_export_env_vars - # Suppress terraform fmt color + # Suppress tofu fmt color if [ "$PRE_COMMIT_COLOR" = "never" ]; then ARGS+=("-no-color") fi @@ -44,7 +44,7 @@ function per_dir_hook_unique_part { local -a -r args=("$@") # pass the arguments to hook - terraform fmt "${args[@]}" + tofu fmt "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? diff --git a/hooks/terraform_providers_lock.sh b/hooks/terraform_providers_lock.sh index c2b09fc..c1015e1 100755 --- a/hooks/terraform_providers_lock.sh +++ b/hooks/terraform_providers_lock.sh @@ -13,7 +13,7 @@ function main { common::parse_cmdline "$@" common::export_provided_env_vars "${ENV_VARS[@]}" common::parse_and_export_env_vars - # JFYI: suppress color for `terraform providers lock` is N/A` + # JFYI: suppress color for `tofu providers lock` is N/A` # shellcheck disable=SC2153 # False positive common::per_dir_hook "$HOOK_ID" "${#ARGS[@]}" "${ARGS[@]}" "${FILES[@]}" @@ -136,7 +136,7 @@ function per_dir_hook_unique_part { common::colorify "yellow" "DEPRECATION NOTICE: We introduced '--mode' flag for this hook. Check migration instructions at https://github.com/tofuutils/pre-commit-opentofu#terraform_providers_lock " - common::terraform_init 'terraform providers lock' "$dir_path" || { + common::tofu_init 'OpenTofu providers lock' "$dir_path" || { exit_code=$? return $exit_code } @@ -149,9 +149,9 @@ Check migration instructions at https://github.com/tofuutils/pre-commit-opentofu fi #? Don't require `tf init` for providers, but required `tf init` for modules - #? Mitigated by `function match_validate_errors` from terraform_validate hook + #? Mitigated by `function match_validate_errors` from tofu_validate hook # pass the arguments to hook - terraform providers lock "${args[@]}" + tofu providers lock "${args[@]}" # return exit code to common::per_dir_hook exit_code=$? diff --git a/hooks/terraform_validate.sh b/hooks/terraform_validate.sh index 2f3795a..0827b9f 100755 --- a/hooks/terraform_validate.sh +++ b/hooks/terraform_validate.sh @@ -7,7 +7,7 @@ readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)" # shellcheck source=_common.sh . "$SCRIPT_DIR/_common.sh" -# `terraform validate` requires this env variable to be set +# `tofu validate` requires this env variable to be set export AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-us-east-1} function main { @@ -16,7 +16,7 @@ function main { common::export_provided_env_vars "${ENV_VARS[@]}" common::parse_and_export_env_vars - # Suppress terraform validate color + # Suppress tofu validate color if [ "$PRE_COMMIT_COLOR" = "never" ]; then ARGS+=("-no-color") fi @@ -25,9 +25,9 @@ function main { } ####################################################################### -# Run `terraform validate` and match errors. Requires `jq` +# Run `tofu validate` and match errors. Requires `jq` # Arguments: -# validate_output (string with json) output of `terraform validate` command +# validate_output (string with json) output of `tofu validate` command # Outputs: # Returns integer: # - 0 (no errors) @@ -66,8 +66,8 @@ function match_validate_errors { ####################################################################### # Unique part of `common::per_dir_hook`. The function is executed in loop # on each provided dir path. Run wrapped tool with specified arguments -# 1. Check if `.terraform` dir exists and if not - run `terraform init` -# 2. Run `terraform validate` +# 1. Check if `.terraform` dir exists and if not - run `tofu init` +# 2. Run `tofu validate` # 3. If at least 1 check failed - change the exit code to non-zero # Arguments: # dir_path (string) PATH to dir relative to git repo root. @@ -111,28 +111,28 @@ function per_dir_hook_unique_part { esac done - # First try `terraform validate` with the hope that all deps are + # First try `terratofuform validate` with the hope that all deps are # pre-installed. That is needed for cases when `.terraform/modules` # or `.terraform/providers` missed AND that is expected. - terraform validate "${args[@]}" &> /dev/null && { + tofu validate "${args[@]}" &> /dev/null && { exit_code=$? return $exit_code } - # In case `terraform validate` failed to execute - # - check is simple `terraform init` will help - common::terraform_init 'terraform validate' "$dir_path" || { + # In case `tofu validate` failed to execute + # - check is simple `tofu init` will help + common::tofu_init 'tofu validate' "$dir_path" || { exit_code=$? return $exit_code } if [ "$retry_once_with_cleanup" != "true" ]; then - # terraform validate only - validate_output=$(terraform validate "${args[@]}" 2>&1) + # tofu validate only + validate_output=$(tofu validate "${args[@]}" 2>&1) exit_code=$? else - # terraform validate, plus capture possible errors - validate_output=$(terraform validate -json "${args[@]}" 2>&1) + # tofu validate, plus capture possible errors + validate_output=$(tofu validate -json "${args[@]}" 2>&1) exit_code=$? # Match specific validation errors @@ -150,12 +150,12 @@ function per_dir_hook_unique_part { common::colorify "yellow" "Re-validating: $dir_path" - common::terraform_init 'terraform validate' "$dir_path" || { + common::tofu_init 'tofu validate' "$dir_path" || { exit_code=$? return $exit_code } - validate_output=$(terraform validate "${args[@]}" 2>&1) + validate_output=$(tofu validate "${args[@]}" 2>&1) exit_code=$? fi fi diff --git a/hooks/terraform_wrapper_module_for_each.sh b/hooks/terraform_wrapper_module_for_each.sh index b01fe46..f1a70ef 100755 --- a/hooks/terraform_wrapper_module_for_each.sh +++ b/hooks/terraform_wrapper_module_for_each.sh @@ -17,7 +17,7 @@ function main { check_dependencies # shellcheck disable=SC2153 # False positive - terraform_module_wrapper_ "${ARGS[*]}" + tofu_module_wrapper_ "${ARGS[*]}" } readonly CONTENT_MAIN_TF='module "wrapper" {}' @@ -38,12 +38,12 @@ readonly CONTENT_OUTPUTS_TF='output "wrapper" { WRAPPER_OUTPUT_SENSITIVE }' readonly CONTENT_VERSIONS_TF='terraform { - required_version = ">= 0.13.1" + required_version = ">= 1.6.0" }' # shellcheck disable=SC2016 # False positive readonly CONTENT_README='# WRAPPER_TITLE -The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native Terraform 0.13+ `for_each` feature is not feasible (e.g., with Terragrunt). +The configuration in this directory contains an implementation of a single module wrapper pattern, which allows managing several copies of a module in places where using the native OpenTofu 1.6.0+ `for_each` feature is not feasible (e.g., with Terragrunt). You may want to use a single Terragrunt configuration file to manage multiple resources without duplicating `terragrunt.hcl` files for each copy of the same module. @@ -64,7 +64,7 @@ inputs = { defaults = { # Default values create = true tags = { - Terraform = "true" + OpenTofu = "true" Environment = "dev" } } @@ -81,7 +81,7 @@ inputs = { } ``` -## Usage with Terraform +## Usage with OpenTofu ```hcl module "wrapper" { @@ -90,7 +90,7 @@ module "wrapper" { defaults = { # Default values create = true tags = { - Terraform = "true" + OpenTofu = "true" Environment = "dev" } } @@ -142,7 +142,7 @@ inputs = { } ```' -function terraform_module_wrapper_ { +function tofu_module_wrapper_ { local args read -r -a args <<< "$1" @@ -197,7 +197,7 @@ function terraform_module_wrapper_ { cat << EOF ERROR: Unrecognized argument: $key Hook ID: $HOOK_ID. -Generate Terraform module wrapper. Available arguments: +Generate OpenTofu module wrapper. Available arguments: --root-dir=... - Root dir of the repository (Optional) --module-dir=... - Single module directory. Options: "." (means just root module), "modules/iam-user" (a single module), or empty (means include all @@ -212,7 +212,7 @@ Generate Terraform module wrapper. Available arguments: Example: --module-dir=modules/object - Generate wrapper for one specific submodule. --module-dir=. - Generate wrapper for the root module. ---module-repo-org=terraform-google-modules --module-repo-shortname=network --module-repo-provider=google - Generate wrappers for repository available by name "terraform-google-modules/network/google" in the Terraform registry and it includes all modules (root and in "modules/*"). +--module-repo-org=terraform-google-modules --module-repo-shortname=network --module-repo-provider=google - Generate wrappers for repository available by name "terraform-google-modules/network/google" in the OpenTofu registry and it includes all modules (root and in "modules/*"). EOF exit 1 ;; @@ -310,7 +310,7 @@ EOF echo fi - # Read content of all terraform files + # Read content of all OpenTofu files # shellcheck disable=SC2207 all_tf_content=$(find "${full_module_dir}" -name '*.tf' -maxdepth 1 -type f -exec cat {} +) @@ -319,15 +319,15 @@ EOF continue fi - # Get names of module variables in all terraform files + # Get names of module variables in all OpenTofu files # shellcheck disable=SC2207 module_vars=($(echo "$all_tf_content" | hcledit block list | { grep "^variable\." | cut -d'.' -f 2 | sort || true; })) - # Get names of module outputs in all terraform files + # Get names of module outputs in all OpenTofu files # shellcheck disable=SC2207 module_outputs=($(echo "$all_tf_content" | hcledit block list | { grep "^output\." | cut -d'.' -f 2 || true; })) - # Get names of module providers in all terraform files + # Get names of module providers in all OpenTofu files module_providers=$(echo "$all_tf_content" | hcledit block list | { grep "^provider\." || true; }) if [[ $module_providers ]]; then @@ -342,7 +342,7 @@ EOF # At least one output is sensitive - the wrapper's output should be sensitive, too if [[ "$module_output_sensitive" == "true" ]]; then - wrapper_output_sensitive="sensitive = true # At least one sensitive module output (${module_output}) found (requires Terraform 0.14+)" + wrapper_output_sensitive="sensitive = true # At least one sensitive module output (${module_output}) found (requires OpenTofu 1.6.0+)" break fi done diff --git a/hooks/terrascan.sh b/hooks/terrascan.sh index ac040b9..3fd46cb 100755 --- a/hooks/terrascan.sh +++ b/hooks/terrascan.sh @@ -40,7 +40,7 @@ function per_dir_hook_unique_part { local -a -r args=("$@") # pass the arguments to hook - terrascan scan -i terraform "${args[@]}" + terrascan scan -i tofu "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? @@ -57,7 +57,7 @@ function run_hook_on_whole_repo { local -a -r args=("$@") # pass the arguments to hook - terrascan scan -i terraform "${args[@]}" + terrascan scan -i tofu "${args[@]}" # return exit code to common::per_dir_hook local exit_code=$? diff --git a/tests/Dockerfile b/tests/Dockerfile index ec77d18..643dce0 100644 --- a/tests/Dockerfile +++ b/tests/Dockerfile @@ -1,4 +1,4 @@ -FROM pre-commit-terraform:latest +FROM pre-commit-opentofu:latest RUN apt update && \ apt install -y \ diff --git a/tests/hooks_performance_test.sh b/tests/hooks_performance_test.sh index 4f35fce..de611c4 100755 --- a/tests/hooks_performance_test.sh +++ b/tests/hooks_performance_test.sh @@ -1,10 +1,10 @@ #!/usr/bin/env bash TEST_NUM=$1 # 1000 -TEST_COMMAND=$2 # 'pre-commit try-repo -a /tmp/159/pre-commit-terraform terraform_tfsec' +TEST_COMMAND=$2 # 'pre-commit try-repo -a /tmp/159/pre-commit-opentofu tofu_tfsec' TEST_DIR=$3 # '/tmp/infrastructure' -TEST_DESCRIPTION="$TEST_NUM runs '$4'" # '`terraform_tfsec` PR #123:' -RAW_TEST_RESULTS_FILE_NAME=$5 # terraform_tfsec_pr123 +TEST_DESCRIPTION="$TEST_NUM runs '$4'" # '`tofu_tfsec` PR #123:' +RAW_TEST_RESULTS_FILE_NAME=$5 # tofu_tfsec_pr123 function run_tests { local TEST_NUM=$1 From 32f93afd65bfd5971aee7a1e6adc124c6be56a33 Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 00:48:28 +0100 Subject: [PATCH 04/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt IV --- .github/CONTRIBUTING.md | 6 ++--- .../bug_report_local_install.md | 2 +- hooks/_common.sh | 2 +- hooks/terraform_docs.sh | 23 ++++++++++--------- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 864893c..8b95ac2 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -27,7 +27,7 @@ pre-commit try-repo {-a} /path/to/local/pre-commit-opentofu/repo {hook_name} I.e. ```bash -pre-commit try-repo /mnt/c/Users/tf/pre-commit-opentofu terraform_fmt # Run only `terraform_fmt` check +pre-commit try-repo /mnt/c/Users/tf/pre-commit-opentofu tofu_fmt # Run only `tofu_fmt` check pre-commit try-repo -a ~/pre-commit-opentofu # run all existing checks from repo ``` @@ -35,10 +35,10 @@ Running `pre-commit` with `try-repo` ignores all arguments specified in `.pre-co If you need to test hook with arguments, follow [pre-commit doc](https://pre-commit.com/#arguments-pattern-in-hooks) to test hooks. -For example, to test that the [`terraform_fmt`](../README.md#terraform_fmt) hook works fine with arguments: +For example, to test that the [`tofu_fmt`](../README.md#tofu_fmt) hook works fine with arguments: ```bash -/tmp/pre-commit-opentofu/terraform_fmt.sh --args=-diff --args=-write=false test-dir/main.tf test-dir/vars.tf +/tmp/pre-commit-opentofu/tofu_fmt.sh --args=-diff --args=-write=false test-dir/main.tf test-dir/vars.tf ``` ## Run hook performance test diff --git a/.github/ISSUE_TEMPLATE/bug_report_local_install.md b/.github/ISSUE_TEMPLATE/bug_report_local_install.md index 26deddd..7f17daf 100644 --- a/.github/ISSUE_TEMPLATE/bug_report_local_install.md +++ b/.github/ISSUE_TEMPLATE/bug_report_local_install.md @@ -78,7 +78,7 @@ Linux DESKTOP-C7315EF 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 bash << EOF bash --version | head -n 1 2>/dev/null || echo "bash SKIPPED" pre-commit --version 2>/dev/null || echo "pre-commit SKIPPED" -terraform --version | head -n 1 2>/dev/null || echo "terraform SKIPPED" +tofu --version | head -n 1 2>/dev/null || echo "tofu SKIPPED" python --version 2>/dev/null || echo "python SKIPPED" python3 --version 2>/dev/null || echo "python3 SKIPPED" echo -n "checkov " && checkov --version 2>/dev/null || echo "checkov SKIPPED" diff --git a/hooks/_common.sh b/hooks/_common.sh index e2dc924..e1a7c48 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -25,7 +25,7 @@ function common::initialize { # Globals (init and populate): # ARGS (array) arguments that configure wrapped tool behavior # HOOK_CONFIG (array) arguments that configure hook behavior -# TF_INIT_ARGS (array) arguments for `terraform init` command +# TF_INIT_ARGS (array) arguments for `tofu init` command # ENV_VARS (array) environment variables will be available # for all 3rd-party tools executed by a hook. # FILES (array) filenames to check diff --git a/hooks/terraform_docs.sh b/hooks/terraform_docs.sh index 9be2808..2b37982 100755 --- a/hooks/terraform_docs.sh +++ b/hooks/terraform_docs.sh @@ -64,37 +64,38 @@ function terraform_docs_ { elif [[ "$hack_terraform_docs" == "1" ]]; then # Using awk script because terraform-docs is older than 0.8 and terraform 0.12 is used if [[ ! $(command -v awk) ]]; then + # TODO: pls check it echo "ERROR: awk is required for terraform-docs hack to work with Terraform 0.12." exit 1 fi local tmp_file_awk - tmp_file_awk=$(mktemp "${TMPDIR:-/tmp}/terraform-docs-XXXXXXXXXX") - terraform_docs_awk "$tmp_file_awk" - terraform_docs "$tmp_file_awk" "${configs[*]}" "$args" "${files[@]}" + tmp_file_awk=$(mktemp "${TMPDIR:-/tmp}/tofu-docs-XXXXXXXXXX") + tofu_docs_awk "$tmp_file_awk" + tofu_docs "$tmp_file_awk" "${configs[*]}" "$args" "${files[@]}" rm -f "$tmp_file_awk" else # Using terraform 0.11 and no awk script is needed for that - - terraform_docs "0" "${configs[*]}" "$args" "${files[@]}" + # TODO: should be deleted for OpenTofu. + tofu_docs "0" "${configs[*]}" "$args" "${files[@]}" fi } ####################################################################### # Wrapper around `terraform-docs` tool that check and change/create -# (depends on provided hook_config) terraform documentation in +# (depends on provided hook_config) OpenTofu documentation in # markdown format # Arguments: # terraform_docs_awk_file (string) filename where awk hack for old # `terraform-docs` was written. Needed for TF 0.12+. -# Hack skipped when `terraform_docs_awk_file == "0"` +# Hack skipped when `tofu_docs_awk_file == "0"` # hook_config (string with array) arguments that configure hook behavior # args (string with array) arguments that configure wrapped tool behavior # files (array) filenames to check ####################################################################### -function terraform_docs { - local -r terraform_docs_awk_file="$1" +function tofu_docs { + local -r tofu_docs_awk_file="$1" local -r hook_config="$2" local args="$3" shift 3 @@ -229,7 +230,7 @@ function terraform_docs { else # Can't append extension for mktemp, so renaming instead local tmp_file_docs - tmp_file_docs=$(mktemp "${TMPDIR:-/tmp}/terraform-docs-XXXXXXXXXX") + tmp_file_docs=$(mktemp "${TMPDIR:-/tmp}/tofu-docs-XXXXXXXXXX") mv "$tmp_file_docs" "$tmp_file_docs.tf" local tmp_file_docs_tf tmp_file_docs_tf="$tmp_file_docs.tf" @@ -263,7 +264,7 @@ function terraform_docs { # Arguments: # output_file (string) filename where hack will be written to ####################################################################### -function terraform_docs_awk { +function tofu_docs_awk { local -r output_file=$1 cat << "EOF" > "$output_file" From 4a43e5d93ae6ec4cf89f64720092aee533cee324 Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 00:52:58 +0100 Subject: [PATCH 05/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt V --- .github/.container-structure-test-config.yaml | 6 +- README.md | 82 +++++++++---------- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/.github/.container-structure-test-config.yaml b/.github/.container-structure-test-config.yaml index 6010765..c06624f 100644 --- a/.github/.container-structure-test-config.yaml +++ b/.github/.container-structure-test-config.yaml @@ -10,10 +10,10 @@ commandTests: args: ["-V"] expectedOutput: ["^pre-commit ([0-9]+\\.){2}[0-9]+\\n$"] - - name: "terraform" - command: "terraform" + - name: "tofu" + command: "terrtofuaform" args: ["-version"] - expectedOutput: ["^Terraform v([0-9]+\\.){2}[0-9]+\\non linux_amd64\\n$"] + expectedOutput: ["^OpenTofu v([0-9]+\\.){2}[0-9]+\\non linux_amd64\\n$"] - name: "checkov" command: "checkov" diff --git a/README.md b/README.md index a5daa97..8efbb71 100644 --- a/README.md +++ b/README.md @@ -648,23 +648,23 @@ To replicate functionality in `terraform_docs` hook: ``` -### terraform_tflint +### tofu_tflint -1. `terraform_tflint` supports custom arguments so you can enable module inspection, enable / disable rules, etc. +1. `tofu_tflint` supports custom arguments so you can enable module inspection, enable / disable rules, etc. Example: ```yaml - - id: terraform_tflint + - id: tofu_tflint args: - --args=--module - --args=--enable-rule=terraform_documented_variables ``` -2. When you have multiple directories and want to run `tflint` in all of them and share a single config file, it is impractical to hard-code the path to the `.tflint.hcl` file. The solution is to use the `__GIT_WORKING_DIR__` placeholder which will be replaced by `terraform_tflint` hooks with the Git working directory (repo root) at run time. For example: +2. When you have multiple directories and want to run `tflint` in all of them and share a single config file, it is impractical to hard-code the path to the `.tflint.hcl` file. The solution is to use the `__GIT_WORKING_DIR__` placeholder which will be replaced by `tofu_tflint` hooks with the Git working directory (repo root) at run time. For example: ```yaml - - id: terraform_tflint + - id: tofu_tflint args: - --args=--config=__GIT_WORKING_DIR__/.tflint.hcl ``` @@ -672,17 +672,17 @@ To replicate functionality in `terraform_docs` hook: 3. By default, pre-commit-opentofu performs directory switching into the terraform 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: ```yaml - - id: terraform_tflint + - id: tofu_tflint args: - --hook-config=--delegate-chdir ``` -### terraform_tfsec (deprecated) +### tofu_tfsec (deprecated) -**DEPRECATED**. [tfsec was replaced by trivy](https://github.com/aquasecurity/tfsec/discussions/1994), so please use [`terraform_trivy`](#terraform_trivy). +**DEPRECATED**. [tfsec was replaced by trivy](https://github.com/aquasecurity/tfsec/discussions/1994), so please use [`tofu_trivy`](#tofu_trivy). -1. `terraform_tfsec` will consume modified files that pre-commit +1. `tofu_tfsec` will consume modified files that pre-commit passes to it, so you can perform whitelisting of directories or files to run against via [files](https://pre-commit.com/#config-files) pre-commit flag @@ -690,7 +690,7 @@ To replicate functionality in `terraform_docs` hook: Example: ```yaml - - id: terraform_tfsec + - id: tofu_tfsec files: ^prd-infra/ ``` @@ -710,10 +710,10 @@ To replicate functionality in `terraform_docs` hook: } ``` -3. `terraform_tfsec` supports custom arguments, so you can pass supported `--no-color` or `--format` (output), `-e` (exclude checks) flags: +3. `tofu_tfsec` supports custom arguments, so you can pass supported `--no-color` or `--format` (output), `-e` (exclude checks) flags: ```yaml - - id: terraform_tfsec + - id: tofu_tfsec args: - > --args=--format json @@ -721,10 +721,10 @@ To replicate functionality in `terraform_docs` hook: -e aws-s3-enable-bucket-logging,aws-s3-specify-public-access-block ``` -4. When you have multiple directories and want to run `tfsec` in all of them and share a single config file - use the `__GIT_WORKING_DIR__` placeholder. It will be replaced by `terraform_tfsec` hooks with Git working directory (repo root) at run time. For example: +4. When you have multiple directories and want to run `tfsec` in all of them and share a single config file - use the `__GIT_WORKING_DIR__` placeholder. It will be replaced by `tofu_tfsec` hooks with Git working directory (repo root) at run time. For example: ```yaml - - id: terraform_tfsec + - id: tofu_tfsec args: - --args=--config-file=__GIT_WORKING_DIR__/.tfsec.json ``` @@ -732,14 +732,14 @@ To replicate functionality in `terraform_docs` hook: Otherwise, will be used files that located in sub-folders: ```yaml - - id: terraform_tfsec + - id: tofu_tfsec args: - --args=--config-file=.tfsec.json ``` -### terraform_trivy +### tofu_trivy -1. `terraform_trivy` will consume modified files that pre-commit +1. `tofu_trivy` will consume modified files that pre-commit passes to it, so you can perform whitelisting of directories or files to run against via [files](https://pre-commit.com/#config-files) pre-commit flag @@ -747,7 +747,7 @@ To replicate functionality in `terraform_docs` hook: Example: ```yaml - - id: terraform_trivy + - id: tofu_trivy files: ^prd-infra/ ``` @@ -769,51 +769,51 @@ To replicate functionality in `terraform_docs` hook: } ``` -3. `terraform_trivy` supports custom arguments, so you can pass supported `--format` (output), `--skip-dirs` (exclude directories) and other flags: +3. `tofu_trivy` supports custom arguments, so you can pass supported `--format` (output), `--skip-dirs` (exclude directories) and other flags: ```yaml - - id: terraform_trivy + - id: tofu_trivy args: - > --args=--format json --skip-dirs="**/.terragrunt-cache" ``` -### terraform_validate +### tofu_validate -1. `terraform_validate` supports custom arguments so you can pass supported `-no-color` or `-json` flags: +1. `tofu_validate` supports custom arguments so you can pass supported `-no-color` or `-json` flags: ```yaml - - id: terraform_validate + - id: tofu_validate args: - --args=-json - --args=-no-color ``` -2. `terraform_validate` also supports passing custom arguments to its `terraform init`: +2. `tofu_validate` also supports passing custom arguments to its `tofu init`: ```yaml - - id: terraform_validate + - id: tofu_validate args: - --tf-init-args=-upgrade - --tf-init-args=-lockfile=readonly ``` -3. It may happen that Terraform working directory (`.terraform`) already exists but not in the best condition (eg, not initialized modules, wrong version of Terraform, etc.). To solve this problem, you can delete broken `.terraform` directories in your repository: +3. It may happen that OpenTofu working directory (`.terraform`) already exists but not in the best condition (eg, not initialized modules, wrong version of OpenTofu, etc.). To solve this problem, you can delete broken `.terraform` directories in your repository: **Option 1** ```yaml - - id: terraform_validate + - id: tofu_validate args: - --hook-config=--retry-once-with-cleanup=true # Boolean. true or false ``` > **Note**: The flag requires additional dependency to be installed: `jq`. - > **Note**: Reinit can be very slow and require downloading data from remote Terraform registries, and not all of that downloaded data or meta-data is currently being cached by Terraform. + > **Note**: Reinit can be very slow and require downloading data from remote OpenTofu registries, and not all of that downloaded data or meta-data is currently being cached by OpenTofu. - When `--retry-once-with-cleanup=true`, in each failed directory the cached modules and providers from the `.terraform` directory will be deleted, before retrying once more. To avoid unnecessary deletion of this directory, the cleanup and retry will only happen if Terraform produces any of the following error messages: + When `--retry-once-with-cleanup=true`, in each failed directory the cached modules and providers from the `.terraform` directory will be deleted, before retrying once more. To avoid unnecessary deletion of this directory, the cleanup and retry will only happen if OpenTofu produces any of the following error messages: * "Missing or corrupted provider plugins" * "Module source has changed" @@ -829,30 +829,30 @@ To replicate functionality in `terraform_docs` hook: ```bash echo " - function rm_terraform { + function rm_tofu { find . \( -iname ".terraform*" ! -iname ".terraform-docs*" \) -print0 | xargs -0 rm -r } " >>~/.bashrc - # Reload shell and use `rm_terraform` command in the repo root + # Reload shell and use `rm_tofu` command in the repo root ``` - `terraform_validate` hook will try to reinitialize them before running the `terraform validate` command. + `tofu_validate` hook will try to reinitialize them before running the `tofu validate` command. **Warning**: If you use Terraform workspaces, DO NOT use this option ([details](https://github.com/tofuutils/pre-commit-opentofu/issues/203#issuecomment-918791847)). Consider the first option, or wait for [`force-init`](https://github.com/tofuutils/pre-commit-opentofu/issues/224) option implementation. -4. `terraform_validate` in a repo with Terraform module, written using Terraform 0.15+ and which uses provider `configuration_aliases` ([Provider Aliases Within Modules](https://www.terraform.io/language/modules/develop/providers#provider-aliases-within-modules)), errors out. +4. `tofu_validate` in a repo with TerrOpenTofuaform module, written using OpenTofu 1.6.0+ and which uses provider `configuration_aliases` ([Provider Aliases Within Modules](https://www.terraform.io/language/modules/develop/providers#provider-aliases-within-modules)), errors out. - When running the hook against Terraform code where you have provider `configuration_aliases` defined in a `required_providers` configuration block, terraform will throw an error like: + When running the hook against OpenTofu code where you have provider `configuration_aliases` defined in a `required_providers` configuration block, OpenTofu will throw an error like: > Error: Provider configuration not present > To work with `` its original provider configuration at provider `["registry.terraform.io/hashicorp/aws"].` is required, but it has been removed. This occurs when a provider configuration is removed while > objects created by that provider still exist in the state. Re-add the provider configuration to destroy ``, after which you can remove the provider configuration again. - This is a [known issue](https://github.com/hashicorp/terraform/issues/28490) with Terraform and how providers are initialized in Terraform 0.15 and later. To work around this you can add an `exclude` parameter to the configuration of `terraform_validate` hook like this: + This is a [known issue](https://github.com/hashicorp/terraform/issues/28490) with OpenTofu and how providers are initialized in OpenTofu 1.6.0 and later. To work around this you can add an `exclude` parameter to the configuration of `tofu_validate` hook like this: ```yaml - - id: terraform_validate + - id: tofu_validate exclude: '^[^/]+$' ``` @@ -930,7 +930,7 @@ If the generated name is incorrect, set them by providing the `module-repo-short ```yaml - id: terrascan args: - - --args=--non-recursive # avoids scan errors on subdirectories without Terraform config files + - --args=--non-recursive # avoids scan errors on subdirectories without OpenTofu config files - --args=--policy-type=azure ``` @@ -942,11 +942,11 @@ If the generated name is incorrect, set them by providing the `module-repo-short ### tfupdate -1. Out of the box `tfupdate` will pin the terraform version: +1. Out of the box `tfupdate` will pin the OpenTofu version: ```yaml - id: tfupdate - name: Autoupdate Terraform versions + name: Autoupdate OpenTofu versions ``` 2. If you'd like to pin providers, etc., use custom arguments, i.e `provider=PROVIDER_NAME`: @@ -989,9 +989,9 @@ $ ls -aldn . drwxr-xr-x 9 1000 1000 4096 Sep 1 16:23 . ``` -### Download Terraform modules from private GitHub repositories +### Download OpenTofu modules from private GitHub repositories -If you use a private Git repository as your Terraform module source, you are required to authenticate to GitHub using a [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). +If you use a private Git repository as your OpenTofu module source, you are required to authenticate to GitHub using a [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). When running pre-commit on Docker, both locally or on CI, you need to configure the [~/.netrc](https://www.gnu.org/software/inetutils/manual/html_node/The-_002enetrc-file.html) file, which contains login and initialization information used by the auto-login process. From 8c07b3a56dcde7e3e2582a30fdff31b456ecb888 Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 00:56:38 +0100 Subject: [PATCH 06/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt VI --- .pre-commit-hooks.yaml | 10 +++++----- README.md | 2 +- hooks/{terraform_checkov.sh => tofu_checkov.sh} | 0 hooks/{terraform_docs.sh => tofu_docs.sh} | 0 ...{terraform_docs_replace.py => tofu_docs_replace.py} | 0 hooks/{terraform_fmt.sh => tofu_fmt.sh} | 0 ...raform_providers_lock.sh => tofu_providers_lock.sh} | 0 hooks/{terraform_tflint.sh => tofu_tflint.sh} | 0 hooks/{terraform_tfsec.sh => tofu_tfsec.sh} | 0 hooks/{terraform_trivy.sh => tofu_trivy.sh} | 0 hooks/{terraform_validate.sh => tofu_validate.sh} | 0 ...ule_for_each.sh => tofu_wrapper_module_for_each.sh} | 0 12 files changed, 6 insertions(+), 6 deletions(-) rename hooks/{terraform_checkov.sh => tofu_checkov.sh} (100%) rename hooks/{terraform_docs.sh => tofu_docs.sh} (100%) rename hooks/{terraform_docs_replace.py => tofu_docs_replace.py} (100%) rename hooks/{terraform_fmt.sh => tofu_fmt.sh} (100%) rename hooks/{terraform_providers_lock.sh => tofu_providers_lock.sh} (100%) rename hooks/{terraform_tflint.sh => tofu_tflint.sh} (100%) rename hooks/{terraform_tfsec.sh => tofu_tfsec.sh} (100%) rename hooks/{terraform_trivy.sh => tofu_trivy.sh} (100%) rename hooks/{terraform_validate.sh => tofu_validate.sh} (100%) rename hooks/{terraform_wrapper_module_for_each.sh => tofu_wrapper_module_for_each.sh} (100%) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index a028149..0a318cc 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -15,8 +15,8 @@ files: (\.tf|\.tfvars)$ exclude: \.terraform\/.*$ -- id: terraform_docs - name: Terraform docs +- id: tofu_docs + name: OpenTofu docs description: Inserts input and output documentation into README.md (using terraform-docs). require_serial: true entry: hooks/terraform_docs.sh @@ -24,11 +24,11 @@ files: (\.tf|\.terraform\.lock\.hcl)$ exclude: \.terraform\/.*$ -- id: terraform_docs_without_aggregate_type_defaults - name: Terraform docs (without aggregate type defaults) +- id: tofu_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. require_serial: true - entry: hooks/terraform_docs.sh + entry: hooks/tofu_docs.sh language: script files: (\.tf)$ exclude: \.terraform\/.*$ diff --git a/README.md b/README.md index 8efbb71..2696eda 100644 --- a/README.md +++ b/README.md @@ -261,7 +261,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform | `terraform_fmt` | Reformat all Terraform configuration files to a canonical format. [Hook notes](#terraform_fmt) | - | | `terraform_providers_lock` | Updates provider signatures in [dependency lock files](https://www.terraform.io/docs/cli/commands/providers/lock.html). [Hook notes](#terraform_providers_lock) | - | | `terraform_tflint` | Validates all Terraform configuration files with [TFLint](https://github.com/terraform-linters/tflint). [Available TFLint rules](https://github.com/terraform-linters/tflint/tree/master/docs/rules#rules). [Hook notes](#terraform_tflint). | `tflint` | -| `terraform_tfsec` | [TFSec](https://github.com/aquasecurity/tfsec) static analysis of terraform templates to spot potential security issues. **DEPRECATED**, use `terraform_trivy`. [Hook notes](#terraform_tfsec-deprecated) | `tfsec` | +| `terraform_tfsec` | [TFSec](https://github.com/aquasecurity/tfsec) static analysis of terraform templates to spot potential security issues. **DEPRECATED**, use `tofu_trivy`. [Hook notes](#terraform_tfsec-deprecated) | `tfsec` | | `terraform_trivy` | [Trivy](https://github.com/aquasecurity/trivy) static analysis of terraform templates to spot potential security issues. [Hook notes](#terraform_trivy) | `trivy` | | `terraform_validate` | Validates all Terraform configuration files. [Hook notes](#terraform_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` | diff --git a/hooks/terraform_checkov.sh b/hooks/tofu_checkov.sh similarity index 100% rename from hooks/terraform_checkov.sh rename to hooks/tofu_checkov.sh diff --git a/hooks/terraform_docs.sh b/hooks/tofu_docs.sh similarity index 100% rename from hooks/terraform_docs.sh rename to hooks/tofu_docs.sh diff --git a/hooks/terraform_docs_replace.py b/hooks/tofu_docs_replace.py similarity index 100% rename from hooks/terraform_docs_replace.py rename to hooks/tofu_docs_replace.py diff --git a/hooks/terraform_fmt.sh b/hooks/tofu_fmt.sh similarity index 100% rename from hooks/terraform_fmt.sh rename to hooks/tofu_fmt.sh diff --git a/hooks/terraform_providers_lock.sh b/hooks/tofu_providers_lock.sh similarity index 100% rename from hooks/terraform_providers_lock.sh rename to hooks/tofu_providers_lock.sh diff --git a/hooks/terraform_tflint.sh b/hooks/tofu_tflint.sh similarity index 100% rename from hooks/terraform_tflint.sh rename to hooks/tofu_tflint.sh diff --git a/hooks/terraform_tfsec.sh b/hooks/tofu_tfsec.sh similarity index 100% rename from hooks/terraform_tfsec.sh rename to hooks/tofu_tfsec.sh diff --git a/hooks/terraform_trivy.sh b/hooks/tofu_trivy.sh similarity index 100% rename from hooks/terraform_trivy.sh rename to hooks/tofu_trivy.sh diff --git a/hooks/terraform_validate.sh b/hooks/tofu_validate.sh similarity index 100% rename from hooks/terraform_validate.sh rename to hooks/tofu_validate.sh diff --git a/hooks/terraform_wrapper_module_for_each.sh b/hooks/tofu_wrapper_module_for_each.sh similarity index 100% rename from hooks/terraform_wrapper_module_for_each.sh rename to hooks/tofu_wrapper_module_for_each.sh From ad6e3254b763ab10606a8a683c89dfbb03f0bd9b Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 01:02:15 +0100 Subject: [PATCH 07/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt VII --- .github/workflows/pre-commit.yaml | 2 +- README.md | 86 +++++++++++++++---------------- hooks/__init__.py | 4 +- hooks/_common.sh | 2 +- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml index 5772950..1085384 100644 --- a/.github/workflows/pre-commit.yaml +++ b/.github/workflows/pre-commit.yaml @@ -35,7 +35,7 @@ jobs: with: fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - # Skip terraform_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 with: python-version: '3.9' diff --git a/README.md b/README.md index 2696eda..6ba3ef8 100644 --- a/README.md +++ b/README.md @@ -504,13 +504,13 @@ Unlike most other hooks, this hook triggers once if there are any changed files - tfvars hcl --output-file terraform.tfvars.model . ``` -### terraform_docs_replace (deprecated) +### tofu_docs_replace (deprecated) -**DEPRECATED**. Will be merged in [`terraform_docs`](#terraform_docs). +**DEPRECATED**. Will be merged in [`tofu_docs`](#tofu_docs). -`terraform_docs_replace` replaces the entire `README.md` rather than doing string replacement between markers. Put your additional documentation at the top of your `main.tf` for it to be pulled in. +`tofu_docs_replace` replaces the entire `README.md` rather than doing string replacement between markers. Put your additional documentation at the top of your `main.tf` for it to be pulled in. -To replicate functionality in `terraform_docs` hook: +To replicate functionality in `tofu_docs` hook: 1. Create `.terraform-docs.yml` in the repo root with the following content: @@ -524,48 +524,48 @@ To replicate functionality in `terraform_docs` hook: {{/** End of file fixer */}} ``` -2. Replace `terraform_docs_replace` hook config in `.pre-commit-config.yaml` with: +2. Replace `tofu_docs_replace` hook config in `.pre-commit-config.yaml` with: ```yaml - - id: terraform_docs + - id: tofu_docs args: - --args=--config=.terraform-docs.yml ``` -### terraform_fmt +### terraftofu_fmtorm_fmt -1. `terraform_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: ```yaml - - id: terraform_fmt + - id: tofu_fmt args: - --args=-no-color - --args=-diff - --args=-write=false ``` -### terraform_providers_lock +### tofu_providers_lock -> **Note**: The hook requires Terraform 0.14 or later. +> **Note**: The hook requires OpenTofu 1.6.0 or later. -> **Note**: The hook can invoke `terraform providers lock` that can be really slow and requires fetching metadata from remote Terraform registries - not all of that metadata is currently being cached by Terraform. +> **Note**: The hook can invoke `tofu providers lock` that can be really slow and requires fetching metadata from remote OpenTofu registries - not all of that metadata is currently being cached by OpenTofu. >
Note: Read this if you used this hook before v1.80.0 | Planned breaking changes in v2.0 > We introduced '--mode' flag for this hook. If you'd like to continue using this hook as before, please: > > * Specify `--hook-config=--mode=always-regenerate-lockfile` in `args:` -> * Before `terraform_providers_lock`, add `terraform_validate` hook with `--hook-config=--retry-once-with-cleanup=true` -> * Move `--tf-init-args=` to `terraform_validate` hook +> * Before `tofu_providers_lock`, add `tofu_validate` hook with `--hook-config=--retry-once-with-cleanup=true` +> * Move `--tf-init-args=` to `tofu_validate` hook > > In the end, you should get config like this: > > ```yaml -> - id: terraform_validate +> - id: tofu_validate > args: > - --hook-config=--retry-once-with-cleanup=true > # - --tf-init-args=-upgrade > -> - id: terraform_providers_lock +> - id: tofu_providers_lock > args: > - --hook-config=--mode=always-regenerate-lockfile > ``` @@ -576,73 +576,73 @@ To replicate functionality in `terraform_docs` hook: >
-1. The hook can work in a few different modes: `only-check-is-current-lockfile-cross-platform` with and without [terraform_validate hook](#terraform_validate) and `always-regenerate-lockfile` - only with terraform_validate hook. +1. The hook can work in a few different modes: `only-check-is-current-lockfile-cross-platform` with and without [tofu_validate hook](#tofu_validate) and `always-regenerate-lockfile` - only with tofu_validate hook. - * `only-check-is-current-lockfile-cross-platform` without terraform_validate - only checks that lockfile has all required SHAs for all providers already added to lockfile. + * `only-check-is-current-lockfile-cross-platform` without tofu_validate - only checks that lockfile has all required SHAs for all providers already added to lockfile. ```yaml - - id: terraform_providers_lock + - id: tofu_providers_lock args: - --hook-config=--mode=only-check-is-current-lockfile-cross-platform ``` - * `only-check-is-current-lockfile-cross-platform` with [terraform_validate hook](#terraform_validate) - make up-to-date lockfile by adding/removing providers and only then check that lockfile has all required SHAs. + * `only-check-is-current-lockfile-cross-platform` with [tofu_validate hook](#tofu_validate) - make up-to-date lockfile by adding/removing providers and only then check that lockfile has all required SHAs. - > **Note**: Next `terraform_validate` flag requires additional dependency to be installed: `jq`. Also, it could run another slow and time consuming command - `terraform init` + > **Note**: Next `tofu_validate` flag requires additional dependency to be installed: `jq`. Also, it could run another slow and time consuming command - `tofu init` ```yaml - - id: terraform_validate + - id: tofu_validate args: - --hook-config=--retry-once-with-cleanup=true - - id: terraform_providers_lock + - id: tofu_providers_lock args: - --hook-config=--mode=only-check-is-current-lockfile-cross-platform ``` - * `always-regenerate-lockfile` only with [terraform_validate hook](#terraform_validate) - regenerate lockfile from scratch. Can be useful for upgrading providers in lockfile to latest versions + * `always-regenerate-lockfile` only with [tofu_validate hook](#tofu_validate) - regenerate lockfile from scratch. Can be useful for upgrading providers in lockfile to latest versions ```yaml - - id: terraform_validate + - id: tofu_validate args: - --hook-config=--retry-once-with-cleanup=true - --tf-init-args=-upgrade - - id: terraform_providers_lock + - id: tofu_providers_lock args: - --hook-config=--mode=always-regenerate-lockfile ``` -3. `terraform_providers_lock` supports custom arguments: +3. `tofu_providers_lock` supports custom arguments: ```yaml - - id: terraform_providers_lock + - id: tofu_providers_lock args: - --args=-platform=windows_amd64 - --args=-platform=darwin_amd64 ``` -4. It may happen that Terraform working directory (`.terraform`) already exists but not in the best condition (eg, not initialized modules, wrong version of Terraform, etc.). To solve this problem, you can find and delete all `.terraform` directories in your repository: +4. It may happen that OpenTofu working directory (`.terraform`) already exists but not in the best condition (eg, not initialized modules, wrong version of OpenTofu, etc.). To solve this problem, you can find and delete all `.terraform` directories in your repository: ```bash echo " - function rm_terraform { + function rm_tofu { find . \( -iname ".terraform*" ! -iname ".terraform-docs*" \) -print0 | xargs -0 rm -r } " >>~/.bashrc - # Reload shell and use `rm_terraform` command in the repo root + # Reload shell and use `rm_tofu` command in the repo root ``` - `terraform_providers_lock` hook will try to reinitialize directories before running the `terraform providers lock` command. + `tofu_providers_lock` hook will try to reinitialize directories before running the `tofu providers lock` command. -5. `terraform_providers_lock` support passing custom arguments to its `terraform init`: +5. `tofu_providers_lock` support passing custom arguments to its `tofu init`: - > **Warning** - DEPRECATION NOTICE: This is available only in `no-mode` mode, which will be removed in v2.0. Please provide this keys to [`terraform_validate`](#terraform_validate) hook, which, to take effect, should be called before `terraform_providers_lock` + > **Warning** - DEPRECATION NOTICE: This is available only in `no-mode` mode, which will be removed in v2.0. Please provide this keys to [`tofu_validate`](#tofu_validate) hook, which, to take effect, should be called before `tofu_providers_lock` ```yaml - - id: terraform_providers_lock + - id: tofu_providers_lock args: - --tf-init-args=-upgrade ``` @@ -839,7 +839,7 @@ To replicate functionality in `terraform_docs` hook: `tofu_validate` hook will try to reinitialize them before running the `tofu validate` command. - **Warning**: If you use Terraform workspaces, DO NOT use this option ([details](https://github.com/tofuutils/pre-commit-opentofu/issues/203#issuecomment-918791847)). Consider the first option, or wait for [`force-init`](https://github.com/tofuutils/pre-commit-opentofu/issues/224) option implementation. + **Warning**: If you use OpenTofu workspaces, DO NOT use this option ([details](https://github.com/tofuutils/pre-commit-opentofu/issues/203#issuecomment-918791847)). Consider the first option, or wait for [`force-init`](https://github.com/tofuutils/pre-commit-opentofu/issues/224) option implementation. 4. `tofu_validate` in a repo with TerrOpenTofuaform module, written using OpenTofu 1.6.0+ and which uses provider `configuration_aliases` ([Provider Aliases Within Modules](https://www.terraform.io/language/modules/develop/providers#provider-aliases-within-modules)), errors out. @@ -878,8 +878,8 @@ To replicate functionality in `terraform_docs` hook: - repos: - repo: local hooks: - - id: generate-terraform-providers - name: generate-terraform-providers + - id: generate-tofu-providers + name: generate-tofu-providers require_serial: true entry: .generate-providers.sh language: script @@ -892,9 +892,9 @@ To replicate functionality in `terraform_docs` hook: > Note: The latter method will leave an "aliased-providers.tf.json" file in your repo. You will either want to automate a way to clean this up or add it to your `.gitignore` or both. -### terraform_wrapper_module_for_each +### tofu_wrapper_module_for_each -`terraform_wrapper_module_for_each` generates module wrappers for Terraform modules (useful for Terragrunt where `for_each` is not supported). When using this hook without arguments it will create wrappers for the root module and all modules available in "modules" directory. +`tofu_wrapper_module_for_each` generates module wrappers for OpenTofu modules (useful for Terragrunt where `for_each` is not supported). When using this hook without arguments it will create wrappers for the root module and all modules available in "modules" directory. You may want to customize some of the options: @@ -906,7 +906,7 @@ You may want to customize some of the options: Sample configuration: ```yaml -- id: terraform_wrapper_module_for_each +- id: tofu_wrapper_module_for_each args: - --args=--module-dir=. # Process only root module - --args=--dry-run # No files will be created/updated @@ -914,11 +914,11 @@ Sample configuration: ``` **If you use hook inside Docker:** -The `terraform_wrapper_module_for_each` hook attempts to determine the module's short name to be inserted into the generated `README.md` files for the `source` URLs. Since the container uses a bind mount at a static location, it can cause this short name to be incorrect. +The `tofu_wrapper_module_for_each` hook attempts to determine the module's short name to be inserted into the generated `README.md` files for the `source` URLs. Since the container uses a bind mount at a static location, it can cause this short name to be incorrect. If the generated name is incorrect, set them by providing the `module-repo-shortname` option to the hook: ```yaml -- id: terraform_wrapper_module_for_each +- id: tofu_wrapper_module_for_each args: - '--args=--module-repo-shortname=ec2-instance' ``` diff --git a/hooks/__init__.py b/hooks/__init__.py index 949d238..b2714f8 100644 --- a/hooks/__init__.py +++ b/hooks/__init__.py @@ -1,4 +1,4 @@ print( - '`terraform_docs_replace` hook is DEPRECATED.' - 'For migration instructions see https://github.com/tofuutils/pre-commit-opentofu/issues/248#issuecomment-1290829226' + '`tofu_docs_replace` hook is DEPRECATED.' + 'TODO: For migration instructions see https://github.com/tofuutils/pre-commit-opentofu/issues/248#issuecomment-1290829226' ) diff --git a/hooks/_common.sh b/hooks/_common.sh index e1a7c48..133e457 100644 --- a/hooks/_common.sh +++ b/hooks/_common.sh @@ -312,7 +312,7 @@ function common::colorify { # Outputs: # If failed - print out tofu init output ####################################################################### -# TODO: v2.0: Move it inside terraform_validate.sh +# TODO: v2.0: Move it inside tofu_validate.sh function common::tofu_init { local -r command_name=$1 local -r dir_path=$2 From 527cbe98cba3d924d40b1f8829273b2c96f64f3c Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 01:10:38 +0100 Subject: [PATCH 08/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt VIII --- .github/CONTRIBUTING.md | 14 +++++++------- .pre-commit-hooks.yaml | 30 ++++++++++++++-------------- README.md | 43 ++++++++++++++++++++--------------------- hooks/tofu_docs.sh | 6 +++--- setup.py | 4 ++-- 5 files changed, 48 insertions(+), 49 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 8b95ac2..86d5bd1 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -50,10 +50,10 @@ Script accept next options: | # | Name | Example value | Description | | --- | ---------------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------- | | 1 | `TEST_NUM` | `200` | How many times need repeat test | -| 2 | `TEST_COMMAND` | `'pre-commit try-repo -a /tmp/159/pre-commit-opentofu terraform_tfsec'` | Valid pre-commit command | +| 2 | `TEST_COMMAND` | `'pre-commit try-repo -a /tmp/159/pre-commit-opentofu tofu_tfsec'` | Valid pre-commit command | | 3 | `TEST_DIR` | `'/tmp/infrastructure'` | Dir on what you run tests. | -| 4 | `TEST_DESCRIPTION` | ```'`terraform_tfsec` PR #123:'``` | Text that you'd like to see in result | -| 5 | `RAW_TEST_`
`RESULTS_FILE_NAME` | `terraform_tfsec_pr123` | (Temporary) File where all test data will be stored. | +| 4 | `TEST_DESCRIPTION` | ```'`tofu_tfsec` PR #123:'``` | Text that you'd like to see in result | +| 5 | `RAW_TEST_`
`RESULTS_FILE_NAME` | `tofu_tfsec_pr123` | (Temporary) File where all test data will be stored. | > **Note:** To make test results repeatable and comparable, be sure that on the test machine nothing generates an unstable workload. During tests good to stop any other apps and do not interact with the test machine. @@ -66,7 +66,7 @@ Script accept next options: # Install deps sudo apt install -y datamash # Run tests -./hooks_performance_test.sh 200 'pre-commit try-repo -a /tmp/159/pre-commit-opentofu terraform_tfsec' '/tmp/infrastructure' '`terraform_tfsec` v1.51.0:' 'terraform_tfsec_pr159' +./hooks_performance_test.sh 200 'pre-commit try-repo -a /tmp/159/pre-commit-opentofu tofu_tfsec' '/tmp/infrastructure' '`tofu_tfsec` v1.51.0:' 'tofu_tfsec_pr159' ``` ### Run via Docker @@ -80,9 +80,9 @@ docker build -t pre-commit-tests tests/ TEST_NUM=1 TEST_DIR='/tmp/infrastructure' PRE_COMMIT_DIR="$(pwd)" -TEST_COMMAND='pre-commit try-repo -a /pct terraform_tfsec' -TEST_DESCRIPTION='`terraform_tfsec` v1.51.0:' -RAW_TEST_RESULTS_FILE_NAME='terraform_tfsec_pr159' +TEST_COMMAND='pre-commit try-repo -a /pct tofu_tfsec' +TEST_DESCRIPTION='`tofu_tfsec` v1.51.0:' +RAW_TEST_RESULTS_FILE_NAME='tofu_tfsec_pr159' docker run -v "$PRE_COMMIT_DIR:/pct:rw" -v "$TEST_DIR:/lint:ro" pre-commit-tests \ $TEST_NUM "$TEST_COMMAND" '/lint' "$RAW_TEST_RESULTS_FILE_NAME" "$RAW_TEST_RESULTS_FILE_NAME" diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 0a318cc..d92c532 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -19,7 +19,7 @@ name: OpenTofu docs description: Inserts input and output documentation into README.md (using terraform-docs). require_serial: true - entry: hooks/terraform_docs.sh + entry: hooks/tofu_docs.sh language: script files: (\.tf|\.terraform\.lock\.hcl)$ exclude: \.terraform\/.*$ @@ -33,8 +33,8 @@ files: (\.tf)$ exclude: \.terraform\/.*$ -- id: terraform_docs_replace - name: Terraform docs (overwrite README.md) +- id: tofu_docs_replace + name: OpenTofu docs (overwrite README.md) description: Overwrite content of README.md with terraform-docs. require_serial: true entry: terraform_docs_replace @@ -51,7 +51,7 @@ files: (\.tf|\.tfvars)$ exclude: \.terraform\/.*$ -- id: terraform_providers_lock +- id: tofu_providers_lock name: Lock OpenTofu provider versions description: Updates provider signatures in dependency lock files. require_serial: true @@ -60,11 +60,11 @@ files: (\.terraform\.lock\.hcl)$ exclude: \.terraform\/.*$ -- id: terraform_tflint +- id: tofu_tflint name: OpenTofu validate with tflint description: Validates all OpenTofu configuration files with TFLint. require_serial: true - entry: hooks/terraform_tflint.sh + entry: hooks/tofu_tflint.sh language: script files: (\.tf|\.tfvars)$ exclude: \.terraform\/.*$ @@ -85,24 +85,24 @@ files: (\.hcl)$ exclude: \.terraform\/.*$ -- id: terraform_tfsec - name: OpenTofu validate with tfsec (deprecated, use "terraform_trivy") +- id: tofu_tfsec + name: OpenTofu validate with tfsec (deprecated, use "tofu_trivy") description: Static analysis of OpenTofu templates to spot potential security issues. require_serial: true - entry: hooks/terraform_tfsec.sh + entry: hooks/tofu_tfsec.sh files: \.tf(vars)?$ language: script -- id: terraform_trivy +- id: tofu_trivy name: OpenTofu validate with trivy description: Static analysis of OpenTofu templates to spot potential security issues. require_serial: true - entry: hooks/terraform_trivy.sh + entry: hooks/tofu_trivy.sh files: \.tf(vars)?$ language: script - id: checkov - name: checkov (deprecated, use "terraform_checkov") + name: checkov (deprecated, use "tofu_checkov") description: Runs checkov on OpenTofu templates. entry: checkov -d . language: python @@ -122,10 +122,10 @@ exclude: \.terraform\/.*$ require_serial: true -- id: terraform_wrapper_module_for_each - name: Terraform wrapper with for_each in module +- id: tofu_wrapper_module_for_each + name: OpenTofu wrapper with for_each in module description: Generate OpenTofu wrappers with for_each in module. - entry: hooks/terraform_wrapper_module_for_each.sh + entry: hooks/tofu_wrapper_module_for_each.sh language: script pass_filenames: false always_run: false diff --git a/README.md b/README.md index 6ba3ef8..8647c14 100644 --- a/README.md +++ b/README.md @@ -23,25 +23,24 @@ If you are using `pre-commit-opentofu` already or want to support its developmen * [All hooks: Usage of environment variables in `--args`](#all-hooks-usage-of-environment-variables-in---args) * [All hooks: Set env vars inside hook at runtime](#all-hooks-set-env-vars-inside-hook-at-runtime) * [All hooks: Disable color output](#all-hooks-disable-color-output) - * [checkov (deprecated) and terraform\_checkov](#checkov-deprecated-and-terraform_checkov) + * [checkov (deprecated) and tofu\_checkov](#checkov-deprecated-and-tofu_checkov) * [infracost\_breakdown](#infracost_breakdown) - * [terraform\_docs](#terraform_docs) - * [terraform\_docs\_replace (deprecated)](#terraform_docs_replace-deprecated) - * [terraform\_fmt](#terraform_fmt) - * [terraform\_providers\_lock](#terraform_providers_lock) - * [terraform\_tflint](#terraform_tflint) - * [terraform\_tfsec (deprecated)](#terraform_tfsec-deprecated) - * [terraform\_trivy](#terraform_trivy) - * [terraform\_validate](#terraform_validate) - * [terraform\_wrapper\_module\_for\_each](#terraform_wrapper_module_for_each) + * [tofu\_docs](#tofu_docs) + * [tofu\_docs\_replace (deprecated)](#tofu_docs_replace-deprecated) + * [tofu\_fmt](#tofu_fmt) + * [tofu\_providers\_lock](#tofu_providers_lock) + * [tofu\_tflint](#tofu_tflint) + * [tofu\_tfsec (deprecated)](#tofu_tfsec-deprecated) + * [tofu\_trivy](#tofu_trivy) + * [tofu\_validate](#tofu_validate) + * [tofu\_wrapper\_module\_for\_each](#tofu_wrapper_module_for_each) * [terrascan](#terrascan) * [tfupdate](#tfupdate) * [Docker Usage](#docker-usage) * [File Permissions](#file-permissions) - * [Download Terraform modules from private GitHub repositories](#download-terraform-modules-from-private-github-repositories) + * [Download OpenTofu modules from private GitHub repositories](#download-tofu-modules-from-private-github-repositories) * [Authors](#authors) * [License](#license) - * [Additional information for users from Russia and Belarus](#additional-information-for-users-from-russia-and-belarus) ## How to install @@ -68,7 +67,7 @@ If you are using `pre-commit-opentofu` already or want to support its developmen * [`TFSec`](https://github.com/liamg/tfsec) required for `terraform_tfsec` hook. * [`Trivy`](https://github.com/aquasecurity/trivy) required for `terraform_trivy` hook. * [`infracost`](https://github.com/infracost/infracost) required for `infracost_breakdown` hook. -* [`jq`](https://github.com/stedolan/jq) required for `terraform_validate` with `--retry-once-with-cleanup` flag, and for `infracost_breakdown` hook. +* [`jq`](https://github.com/stedolan/jq) required for `tofu_validate` with `--retry-once-with-cleanup` flag, and for `infracost_breakdown` hook. * [`tfupdate`](https://github.com/minamijoyo/tfupdate) required for `tfupdate` hook. * [`hcledit`](https://github.com/minamijoyo/hcledit) required for `terraform_wrapper_module_for_each` hook. @@ -263,7 +262,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform | `terraform_tflint` | Validates all Terraform configuration files with [TFLint](https://github.com/terraform-linters/tflint). [Available TFLint rules](https://github.com/terraform-linters/tflint/tree/master/docs/rules#rules). [Hook notes](#terraform_tflint). | `tflint` | | `terraform_tfsec` | [TFSec](https://github.com/aquasecurity/tfsec) static analysis of terraform templates to spot potential security issues. **DEPRECATED**, use `tofu_trivy`. [Hook notes](#terraform_tfsec-deprecated) | `tfsec` | | `terraform_trivy` | [Trivy](https://github.com/aquasecurity/trivy) static analysis of terraform templates to spot potential security issues. [Hook notes](#terraform_trivy) | `trivy` | -| `terraform_validate` | Validates all Terraform configuration files. [Hook notes](#terraform_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_validate` | Validates all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) | `terragrunt` | | `terraform_wrapper_module_for_each` | Generates Terraform wrappers with `for_each` in module. [Hook notes](#terraform_wrapper_module_for_each) | `hcledit` | @@ -290,7 +289,7 @@ You can use environment variables for the `--args` section. Config example: ```yaml -- id: terraform_tflint +- id: tofu_tflint args: - --args=--config=${CONFIG_NAME}.${CONFIG_EXT} - --args=--module @@ -307,7 +306,7 @@ You can specify environment variables that will be passed to the hook at runtime Config example: ```yaml -- id: terraform_validate +- id: tofu_validate args: - --env-vars=AWS_DEFAULT_REGION="us-west-2" - --env-vars=AWS_ACCESS_KEY_ID="anaccesskey" @@ -453,7 +452,7 @@ Unlike most other hooks, this hook triggers once if there are any changed files ### terraform_docs -1. `terraform_docs` and `terraform_docs_without_aggregate_type_defaults` will insert/update documentation generated by [terraform-docs](https://github.com/terraform-docs/terraform-docs) framed by markers: +1. `tofu_docs` and `terraform_docs_without_aggregate_type_defaults` will insert/update documentation generated by [terraform-docs](https://github.com/terraform-docs/terraform-docs) framed by markers: ```txt @@ -463,7 +462,7 @@ Unlike most other hooks, this hook triggers once if there are any changed files if they are present in `README.md`. -2. It is possible to pass additional arguments to shell scripts when using `terraform_docs` and `terraform_docs_without_aggregate_type_defaults`. +2. It is possible to pass additional arguments to shell scripts when using `tofu_docs` and `tofu_docs_without_aggregate_type_defaults`. 3. It is possible to automatically: * create a documentation file @@ -478,7 +477,7 @@ Unlike most other hooks, this hook triggers once if there are any changed files ``` ```yaml - - id: terraform_docs + - id: tofu_docs args: - --hook-config=--path-to-file=README.md # Valid UNIX path. I.e. ../TFDOC.md or docs/README.md etc. - --hook-config=--add-to-existing-file=true # Boolean. true or false @@ -486,10 +485,10 @@ Unlike most other hooks, this hook triggers once if there are any changed files - --hook-config=--use-standard-markers=true # Boolean. Defaults in v1.x to false. Set to true for compatibility with terraform-docs ``` -4. You can provide [any configuration available in `terraform-docs`](https://terraform-docs.io/user-guide/configuration/) as an argument to `terraform_doc` hook, for example: +4. You can provide [any configuration available in `tofu-docs`](https://terraform-docs.io/user-guide/configuration/) as an argument to `tofu_doc` hook, for example: ```yaml - - id: terraform_docs + - id: tofu_docs args: - --args=--config=.terraform-docs.yml ``` @@ -499,7 +498,7 @@ Unlike most other hooks, this hook triggers once if there are any changed files 5. If you need some exotic settings, it can be done too. I.e. this one generates HCL files: ```yaml - - id: terraform_docs + - id: tofu_docs args: - tfvars hcl --output-file terraform.tfvars.model . ``` diff --git a/hooks/tofu_docs.sh b/hooks/tofu_docs.sh index 2b37982..386929c 100755 --- a/hooks/tofu_docs.sh +++ b/hooks/tofu_docs.sh @@ -30,14 +30,14 @@ function main { } ####################################################################### -# Function which prepares hacks for old versions of `terraform` and +# TODO Function which prepares hacks for old versions of `terraform` and # `terraform-docs` that them call `terraform_docs` # Arguments: # hook_config (string with array) arguments that configure hook behavior # args (string with array) arguments that configure wrapped tool behavior # files (array) filenames to check ####################################################################### -function terraform_docs_ { +function tofu_docs_ { local -r hook_config="$1" local -r args="$2" shift 2 @@ -46,7 +46,7 @@ function terraform_docs_ { # Get hook settings IFS=";" read -r -a configs <<< "$hook_config" - local hack_terraform_docs + local hack_tofu_docs hack_terraform_docs=$(terraform version | sed -n 1p | grep -c 0.12) || true if [[ ! $(command -v terraform-docs) ]]; then diff --git a/setup.py b/setup.py index 3168c93..ea944ad 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ from setuptools import setup setup( name='pre-commit-opentofu', - description='Pre-commit hooks for terraform_docs_replace', + description='Pre-commit hooks for tofu_docs_replace', url='https://github.com/tofuutils/pre-commit-opentofu', version_format='{tag}+{gitsha}', @@ -27,7 +27,7 @@ setup( ], entry_points={ 'console_scripts': [ - 'terraform_docs_replace = hooks.terraform_docs_replace:main', + 'tofu_docs_replace = hooks.tofu_docs_replace:main', ], }, ) From d4c409dfffc362e71bf85fa781e42c2f96b56c87 Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 01:14:36 +0100 Subject: [PATCH 09/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt IX --- Dockerfile | 10 +++++----- README.md | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index fcf33f2..0084c13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,17 +14,17 @@ RUN apk add --no-cache \ setuptools ARG PRE_COMMIT_VERSION=${PRE_COMMIT_VERSION:-latest} -ARG TERRAFORM_VERSION=${TERRAFORM_VERSION:-latest} +ARG TOFU_VERSION=${TOFU_VERSION:-latest} # Install pre-commit RUN [ ${PRE_COMMIT_VERSION} = "latest" ] && pip3 install --no-cache-dir pre-commit \ || pip3 install --no-cache-dir pre-commit==${PRE_COMMIT_VERSION} -# Install terraform because pre-commit needs it -RUN if [ "${TERRAFORM_VERSION}" = "latest" ]; then \ - TERRAFORM_VERSION="$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | grep tag_name | grep -o -E -m 1 "[0-9.]+")" \ +# TODO Install OpenTofu because pre-commit needs it +RUN if [ "${TOFU_VERSION}" = "latest" ]; then \ + TOFU_VERSION="$(curl -s https://api.github.com/repos/hashicorp/terraform/releases/latest | grep tag_name | grep -o -E -m 1 "[0-9.]+")" \ ; fi && \ - curl -L "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_${TARGETOS}_${TARGETARCH}.zip" > terraform.zip && \ + curl -L "https://releases.hashicorp.com/terraform/${TOFU_VERSION}/terraform_${TOFU_VERSION}_${TARGETOS}_${TARGETARCH}.zip" > terraform.zip && \ unzip terraform.zip terraform && rm terraform.zip # diff --git a/README.md b/README.md index 8647c14..7750c39 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ To install a specific version of individual tools, define it using `--build-arg` ```bash docker build -t pre-commit-opentofu \ --build-arg PRE_COMMIT_VERSION=latest \ - --build-arg TERRAFORM_VERSION=latest \ + --build-arg TOFU_VERSION=latest \ --build-arg CHECKOV_VERSION=2.0.405 \ --build-arg INFRACOST_VERSION=latest \ --build-arg TERRAFORM_DOCS_VERSION=0.15.0 \ @@ -265,7 +265,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform | `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_validate` | Validates all [Terragrunt](https://github.com/gruntwork-io/terragrunt) configuration files (`*.hcl`) | `terragrunt` | -| `terraform_wrapper_module_for_each` | Generates Terraform 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` | | `tfupdate` | [tfupdate](https://github.com/minamijoyo/tfupdate) Update version constraints of Terraform core, providers, and modules. [Hook notes](#tfupdate) | `tfupdate` | @@ -276,11 +276,11 @@ Check the [source file](https://github.com/tofuutils/pre-commit-opentofu/blob/ma ### Known limitations -Terraform 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). ### All hooks: Usage of environment variables in `--args` -> All, except deprecated hooks: `checkov`, `terraform_docs_replace` +> All, except deprecated hooks: `checkov`, `tofu_docs_replace` You can use environment variables for the `--args` section. @@ -299,7 +299,7 @@ If for config above set up `export CONFIG_NAME=.tflint; export CONFIG_EXT=hcl` b ### All hooks: Set env vars inside hook at runtime -> All, except deprecated hooks: `checkov`, `terraform_docs_replace` +> All, except deprecated hooks: `checkov`, `tofu_docs_replace` You can specify environment variables that will be passed to the hook at runtime. @@ -315,7 +315,7 @@ Config example: ### All hooks: Disable color output -> All, except deprecated hooks: `checkov`, `terraform_docs_replace` +> All, except deprecated hooks: `checkov`, `tofu_docs_replace` To disable color output for all hooks, set `PRE_COMMIT_COLOR=never` var. Eg: @@ -323,16 +323,16 @@ To disable color output for all hooks, set `PRE_COMMIT_COLOR=never` var. Eg: PRE_COMMIT_COLOR=never pre-commit run ``` -### checkov (deprecated) and terraform_checkov +### checkov (deprecated) and tofu_checkov -> `checkov` hook is deprecated, please use `terraform_checkov`. +> `checkov` hook is deprecated, please use `tofu_checkov`. -Note that `terraform_checkov` runs recursively during `-d .` usage. That means, for example, if you change `.tf` file in repo root, all existing `.tf` files in the repo will be checked. +Note that `tofu_checkov` runs recursively during `-d .` usage. That means, for example, if you change `.tf` file in repo root, all existing `.tf` files in the repo will be checked. 1. You can specify custom arguments. E.g.: ```yaml - - id: terraform_checkov + - id: tofu_checkov args: - --args=--quiet - --args=--skip-check CKV2_AWS_8 From a8ef967e92804b091f67633dbec131420fbff06c Mon Sep 17 00:00:00 2001 From: Alexander Sharov Date: Wed, 17 Jan 2024 01:15:52 +0100 Subject: [PATCH 10/10] feat: rename pre-commit-terraform to pre-commit-opentofu, pt X --- README.md | 6 +++--- hooks/tofu_docs.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7750c39..5fcff2b 100644 --- a/README.md +++ b/README.md @@ -216,8 +216,8 @@ repos: - repo: https://github.com/tofuutils/pre-commit-opentofu rev: # Get the latest from: https://github.com/tofuutils/pre-commit-opentofu/releases hooks: - - id: terraform_fmt - - id: terraform_docs + - id: tofu_fmt + - id: tofu_docs EOF ``` @@ -252,7 +252,7 @@ There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform | Hook name | Description | Dependencies
[Install instructions here](#1-install-dependencies) | | ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | -| `checkov` and `terraform_checkov` | [checkov](https://github.com/bridgecrewio/checkov) static analysis of terraform templates to spot potential security issues. [Hook notes](#checkov-deprecated-and-terraform_checkov) | `checkov`
Ubuntu deps: `python3`, `python3-pip` | +| `checkov` and `tofu_checkov` | [checkov](https://github.com/bridgecrewio/checkov) static analysis of OpenTofu templates to spot potential security issues. [Hook notes](#checkov-deprecated-and-tofu_checkov) | `checkov`
Ubuntu deps: `python3`, `python3-pip` | | `infracost_breakdown` | Check how much your infra costs with [infracost](https://github.com/infracost/infracost). [Hook notes](#infracost_breakdown) | `infracost`, `jq`, [Infracost API key](https://www.infracost.io/docs/#2-get-api-key) | | `terraform_docs` | Inserts input and output documentation into `README.md`. Recommended. [Hook notes](#terraform_docs) | `terraform-docs` | | `terraform_docs_replace` | Runs `terraform-docs` and pipes the output directly to README.md. **DEPRECATED**, see [#248](https://github.com/tofuutils/pre-commit-opentofu/issues/248). [Hook notes](#terraform_docs_replace-deprecated) | `python3`, `terraform-docs` | diff --git a/hooks/tofu_docs.sh b/hooks/tofu_docs.sh index 386929c..308b26f 100755 --- a/hooks/tofu_docs.sh +++ b/hooks/tofu_docs.sh @@ -47,7 +47,7 @@ function tofu_docs_ { IFS=";" read -r -a configs <<< "$hook_config" local hack_tofu_docs - hack_terraform_docs=$(terraform version | sed -n 1p | grep -c 0.12) || true + hack_terraform_docs=$(tofu version | sed -n 1p | grep -c 0.12) || true if [[ ! $(command -v terraform-docs) ]]; then echo "ERROR: terraform-docs is required by terraform_docs pre-commit hook but is not installed or in the system's PATH."