8000 GitHub - devopsforhumans/tf-pre-commit at refs/heads/main
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

devopsforhumans/tf-pre-commit

 
 

Repository files navigation

tf-pre-commit

Python base simple terraform pre-commit hook.

Python Version

Requires python version 3.9 or above.

Table of Contents

Using tf-pre-commit with pre-commit

Add the following repo to your .pre-commit-config.yaml

...
  - repo: https://github.com/devopsforhumans/tf-pre-commit
    rev: v1.0.4
    hooks:
      - id: terraform-fmt
...

if you want to provide options or global options (try terraform fmt --help) then use args

...
  - repo: https://github.com/devopsforhumans/tf-pre-commit.git
    rev: v1.0.4
    hooks:
      - id: terraform-fmt
        args:
          - --options="-no-color -diff -check"
...

Note If -recursive is provided in the --options argument, terraform formatting will recursively format the parent directory of the file in context.

Development

  • Create virtual environment

    python3 -m venv .venv
  • Activate virtual environment

    source .venv/bin/activate

    or for windows

    .\.venv\Scripts\activate.ps1
  • Install dependencies

    To install dependencies with pipenv use the following command

    python3 -m pip install -r requirements.txt

    To install dev dependencies use --dev flag

    python3 -m pip install -r requirements_dev.txt

License

tf-pre-commit is distributed under the terms of the BSD-3-Clause license.

0