This is a set of pre-commit hooks intended for projects using Packer.
Hook name | Description |
---|---|
packer_fmt |
Rewrites all Packer configuration files to a canonical format. |
packer_validate |
Validates all Packer configuration files. |
repos:
- repo: https://github.com/cisagov/pre-commit-packer
rev: <version> # Version from https://github.com/cisagov/pre-commit-packer/releases
hooks:
- id: packer_fmt
- id: packer_validate
args:
- '--args=--var-file=inputs/dev.pkrvars.hcl'
This hook scans any files in the packer configuration ending in packer.json
,.pkr.hcl
and .pkrvars.hcl
and applies packer formatting.
-
packer_validate
supports custom arguments so you can pass supported no-color or json flags.- Example:
hooks: - id: packer_validate args: ['--args=-json']
In order to pass multiple args, try the following:
- id: packer_validate args: - '--args=-json' - '--args=-no-color'
-
packer_validate
also supports custom environment variables passed to the pre-commit runtime- Example:
hooks: - id: packer_validate args: ['--envs=AWS_DEFAULT_REGION="us-west-2"']
In order to pass multiple args, try the following:
- id: packer_validate args: - '--envs=AWS_DEFAULT_REGION="us-west-2"' - '--envs=AWS_ACCESS_KEY_ID="anaccesskey"' - '--envs=AWS_SECRET_ACCESS_KEY="asecretkey"'
-
packer_validate
also supports custom arguments allowing to choose the input pkrvars.hcl passed to the pre-commit runtime to validate your packer configuration- Example:
hooks: - id: packer_validate args: - '--args=--var-file=inputs/dev.pkrvars.hcl'
We welcome contributions! Please see CONTRIBUTING.md
for
details.
This project is in the worldwide public domain.
This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the CC0 1.0 Universal public domain dedication.
All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest.