Miscellaneous hooks for pre-commit.
-
check-zero-width-spaces
- Forbid files which have one or more zero width spaces (U+200B). -
hadolint
- Run Hadolint on Dockerfiles.- You may use any Hadolint CLI argument, e.g.
--config example.yaml
,--ignore RULE
,--trusted-registry REGISTRY
, etc. See the example below.
- You may use any Hadolint CLI argument, e.g.
-
nomad-fmt
- Runnomad fmt
on Nomad manifests. -
packer-validate
- Runpacker validate
on JSON files.
-
Install dependencies:
- pre-commit
- Hadolint (for
hadolint
) - Packer (for
packer-validate
)
-
Install the pre-commit hook globally:
$ pre-commit init-templatedir -t pre-commit ~/.git-template
-
Create the
.pre-commit-config.yaml
file:$ cd /path/to/my/repo/ $ vim .pre-commit-config.yaml
Tip: use the example from the next section as a start point.
-
Run:
$ pre-commit run -a
# .pre-commit-config.yaml
repos:
- repo: https://github.com/flaudisio/pre-commit-hooks
rev: v0.11.0
hooks:
- id: check-zero-width-spaces
- id: hadolint
args:
- --config .hadolint.strict.yaml
- --ignore DL3013
- --ignore DL3018
- --trusted-registry registry.example.com:5000
exclude: ^cookiecutter/.+/Dockerfile$
- id: packer-validate
files: ^templates/.+\.json$
MIT.