Packer-specific hooks for use with pre-commit.
pre-commit
version1.15.0
or newer
packer
for hooks that are prefixed withpacker-
docker
for hooks that are prefixed withdocker-
The hooks in this repository can be used by adding the following stub to your .pre-commit-config.yaml
file:
---
-
repo: https://github.com/operatehappy/pre-commit-packer
rev: 1.0.0
hooks:
- id: packer-validate
files: packer*.json
- id: packer-fix
files: packer*.json
- id: packer-validate-and-fix
files: packer*.json
-
packer-validate
wraps thevalidate
command to parse Packer template(s) and check template configuration against any used builders, provisioners, and processors. -
packer-fix
wraps thefix
command and attempts to fix (known) backwards incompatibilities in Packer template(s). -
packer-validate-and-fix
wraps thefix
command and additionally validates the fixed Packer template(s).
All hooks accept the following configuration options:
files
accepts a string (wildcards are supported) to define which file(s) the hook should targetargs
accepts an array with one or more valid command-specific CLI arguments
The files
configuration option defaults to packer.json
The args
configuration option is most useful with the packer-validate
action as it allows for passing additional arguments such as a path to a variables file (-var-file=packer.vars.json
). The upstream documentation for the validate
command provides an overview of all available options.
The hooks provided by pre-commit-packer
support invocation through a containerized version of the Packer Docker Image.
This invocation defaults to the light
tag, but is otherwise functionally identical to a direct invocation via the packer
binary.
The Docker-specific hooks are prefixed with docker-
:
packer-validate
becomesdocker-packer-validate
packer-fix
becomesdocker-packer-fix
packer-validate-and-fix
becomesdocker-packer-validate-and-fix
- In the code example, the
1.0.0
version ofpre-commit-packer
has been selected. The Releases tab provides an overview of all available versions.
This repository is maintained by the contributors listed on GitHub
Development of this module was sponsored by Operate Happy.
Licensed under the Apache License, Version 2.0 (the "License").
You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" basis, without WARRANTIES or conditions of any kind, either express or implied.
See the License for the specific language governing permissions and limitations under the License.