forked from github/pre-commit-opentofu
fix: docs
This commit is contained in:
parent
02ebd94241
commit
5e0e10c2d8
3 changed files with 37 additions and 16 deletions
|
|
@ -7,4 +7,4 @@ All notable changes to this project will be documented in this file.
|
|||
|
||||
### Features
|
||||
|
||||
* TODO
|
||||
* TODO
|
||||
|
|
|
|||
4
LICENSE
4
LICENSE
|
|
@ -1,5 +1,5 @@
|
|||
Copyright (c) 2017 Anton Babenko
|
||||
Copyright (c) 2024 ttofuutils authors
|
||||
Copyright (c) 2017 Anton Babenko, https://github.com/antonbabenko/pre-commit-terraform
|
||||
Copyright (c) 2024 tofuutils authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
|
|
|
|||
47
README.md
47
README.md
|
|
@ -1,6 +1,6 @@
|
|||
# Collection of git hooks for OpenTofu to be used with [pre-commit framework](http://pre-commit.com/)
|
||||
|
||||
[](https://github.com/tofuutils/pre-commit-opentofu/releases)  [](https://www.codetriage.com/tofuutils/pre-commit-opentofu)
|
||||
[](https://github.com/tofuutils/pre-commit-opentofu/releases)  [](https://www.codetriage.com/tofuutils/pre-commit-opentofu)
|
||||
|
||||
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).
|
||||
|
||||
|
|
@ -10,7 +10,6 @@ If you are using `pre-commit-opentofu` already or want to support its developmen
|
|||
|
||||
## Table of content
|
||||
|
||||
* [Sponsors](#sponsors)
|
||||
* [Table of content](#table-of-content)
|
||||
* [How to install](#how-to-install)
|
||||
* [1. Install dependencies](#1-install-dependencies)
|
||||
|
|
@ -49,7 +48,7 @@ If you are using `pre-commit-opentofu` already or want to support its developmen
|
|||
<!-- markdownlint-disable no-inline-html -->
|
||||
|
||||
* [`pre-commit`](https://pre-commit.com/#install),
|
||||
<sub><sup>[`terraform`](https://www.terraform.io/downloads.html),
|
||||
<sub><sup>[`opentofu`](https://opentofu.org/docs/intro/install/),
|
||||
<sub><sup>[`git`](https://git-scm.com/downloads),
|
||||
<sub><sup>POSIX compatible shell,
|
||||
<sub><sup>Internet connection (on first run),
|
||||
|
|
@ -59,17 +58,17 @@ If you are using `pre-commit-opentofu` already or want to support its developmen
|
|||
<sub><sup>Some basic physical laws,
|
||||
<sub><sup>Hope that it all will work.
|
||||
</sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub></sup></sub><br><br>
|
||||
* [`checkov`](https://github.com/bridgecrewio/checkov) required for `terraform_checkov` hook.
|
||||
* [`terraform-docs`](https://github.com/terraform-docs/terraform-docs) required for `terraform_docs` hook.
|
||||
* [`checkov`](https://github.com/bridgecrewio/checkov) required for `tofu_checkov` hook.
|
||||
* [`terraform-docs`](https://github.com/terraform-docs/terraform-docs) required for `tofu_docs` hook.
|
||||
* [`terragrunt`](https://terragrunt.gruntwork.io/docs/getting-started/install/) required for `terragrunt_validate` hook.
|
||||
* [`terrascan`](https://github.com/tenable/terrascan) required for `terrascan` hook.
|
||||
* [`TFLint`](https://github.com/terraform-linters/tflint) required for `terraform_tflint` hook.
|
||||
* [`TFSec`](https://github.com/liamg/tfsec) required for `terraform_tfsec` hook.
|
||||
* [`Trivy`](https://github.com/aquasecurity/trivy) required for `terraform_trivy` hook.
|
||||
* [`TFLint`](https://github.com/terraform-linters/tflint) required for `tofu_tflint` hook.
|
||||
* [`TFSec`](https://github.com/liamg/tfsec) required for `tofu_tfsec` hook.
|
||||
* [`Trivy`](https://github.com/aquasecurity/trivy) required for `tofu_trivy` hook.
|
||||
* [`infracost`](https://github.com/infracost/infracost) required 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.
|
||||
* [`hcledit`](https://github.com/minamijoyo/hcledit) required for `tofu_wrapper_module_for_each` hook.
|
||||
|
||||
<details><summary><b>Docker</b></summary><br>
|
||||
|
||||
|
|
@ -87,7 +86,7 @@ All available tags [here](https://github.com/tofuutils/pre-commit-opentofu/pkgs/
|
|||
> **Note**: To build image you need to have [`docker buildx`](https://docs.docker.com/build/install-buildx/) enabled as default builder.
|
||||
> Otherwise - provide `TARGETOS` and `TARGETARCH` as additional `--build-arg`'s to `docker build`.
|
||||
|
||||
When hooks-related `--build-arg`s are not specified, only the latest version of `pre-commit` and `terraform` will be installed.
|
||||
When hooks-related `--build-arg`s are not specified, only the latest version of `pre-commit` and `opentofu` will be installed.
|
||||
|
||||
```bash
|
||||
git clone git@github.com:tofuutils/pre-commit-opentofu.git
|
||||
|
|
@ -173,6 +172,28 @@ curl -L "$(curl -s https://api.github.com/repos/minamijoyo/hcledit/releases/late
|
|||
|
||||
</details>
|
||||
|
||||
<details><summary><b>Ubuntu 22.04</b></summary><br>
|
||||
|
||||
```bash
|
||||
sudo apt update
|
||||
sudo apt install -y unzip software-properties-common python3 python3-pip
|
||||
python3 -m pip install --upgrade pip
|
||||
pip3 install --no-cache-dir pre-commit
|
||||
pip3 install --no-cache-dir checkov
|
||||
curl -L "$(curl -s https://api.github.com/repos/terraform-docs/terraform-docs/releases/latest | grep -o -E -m 1 "https://.+?-linux-amd64.tar.gz")" > terraform-docs.tgz && tar -xzf terraform-docs.tgz terraform-docs && rm terraform-docs.tgz && chmod +x terraform-docs && sudo mv terraform-docs /usr/bin/
|
||||
curl -L "$(curl -s https://api.github.com/repos/tenable/terrascan/releases/latest | grep -o -E -m 1 "https://.+?_Linux_x86_64.tar.gz")" > terrascan.tar.gz && tar -xzf terrascan.tar.gz terrascan && rm terrascan.tar.gz && sudo mv terrascan /usr/bin/ && terrascan init
|
||||
curl -L "$(curl -s https://api.github.com/repos/terraform-linters/tflint/releases/latest | grep -o -E -m 1 "https://.+?_linux_amd64.zip")" > tflint.zip && unzip tflint.zip && rm tflint.zip && sudo mv tflint /usr/bin/
|
||||
curl -L "$(curl -s https://api.github.com/repos/aquasecurity/tfsec/releases/latest | grep -o -E -m 1 "https://.+?tfsec-linux-amd64")" > tfsec && chmod +x tfsec && sudo mv tfsec /usr/bin/
|
||||
curl -L "$(curl -s https://api.github.com/repos/aquasecurity/trivy/releases/latest | grep -o -E -i -m 1 "https://.+?/trivy_.+?_Linux-64bit.tar.gz")" > trivy.tar.gz && tar -xzf trivy.tar.gz trivy && rm trivy.tar.gz && sudo mv trivy /usr/bin
|
||||
sudo apt install -y jq && \
|
||||
curl -L "$(curl -s https://api.github.com/repos/infracost/infracost/releases/latest | grep -o -E -m 1 "https://.+?-linux-amd64.tar.gz")" > infracost.tgz && tar -xzf infracost.tgz && rm infracost.tgz && sudo mv infracost-linux-amd64 /usr/bin/infracost && infracost register
|
||||
curl -L "$(curl -s https://api.github.com/repos/minamijoyo/tfupdate/releases/latest | grep -o -E -m 1 "https://.+?_linux_amd64.tar.gz")" > tfupdate.tar.gz && tar -xzf tfupdate.tar.gz tfupdate && rm tfupdate.tar.gz && sudo mv tfupdate /usr/bin/
|
||||
curl -L "$(curl -s https://api.github.com/repos/minamijoyo/hcledit/releases/latest | grep -o -E -m 1 "https://.+?_linux_amd64.tar.gz")" > hcledit.tar.gz && tar -xzf hcledit.tar.gz hcledit && rm hcledit.tar.gz && sudo mv hcledit /usr/bin/
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
<details><summary><b>Windows 10/11</b></summary>
|
||||
|
||||
We highly recommend using [WSL/WSL2](https://docs.microsoft.com/en-us/windows/wsl/install) with Ubuntu and following the Ubuntu installation guide. Or use Docker.
|
||||
|
|
@ -247,16 +268,16 @@ docker run --rm --entrypoint cat ghcr.io/tofuutils/pre-commit-opentofu:$TAG /usr
|
|||
|
||||
## Available Hooks
|
||||
|
||||
There are several [pre-commit](https://pre-commit.com/) hooks to keep Terraform configurations (both `*.tf` and `*.tfvars`) and Terragrunt configurations (`*.hcl`) in a good shape:
|
||||
There are several [pre-commit](https://pre-commit.com/) hooks to keep OpenTofu configurations (both `*.tf` and `*.tfvars`) and Terragrunt configurations (`*.hcl`) in a good shape:
|
||||
|
||||
<!-- markdownlint-disable no-inline-html -->
|
||||
| Hook name | Description | Dependencies<br><sup>[Install instructions here](#1-install-dependencies)</sup> |
|
||||
| ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
|
||||
| `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`<br>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` |
|
||||
| `tofu_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` |
|
||||
| `terraform_docs_without_`<br>`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_docs_without_`<br>`aggregate_type_defaults` | Inserts input and output documentation into `README.md` without aggregate type defaults. Hook notes same as for [tofu_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) | - |
|
||||
| `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` |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue