Skip to content

Commit

Permalink
Ensure Packer files are validated (#61)
Browse files Browse the repository at this point in the history
* Ensure that packer validate is executed on a directory
* Ensure that packer validate is restricted to modern HCL2
  Packer templates and corresponding file suffixes
  • Loading branch information
tpdownes authored Oct 5, 2021
1 parent bec6578 commit 3544d29
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
description: Validates all Packer configuration files
entry: hooks/packer-validate.sh
language: script
files: \.pkr.*$
files: (\.pkr\.(hcl|json)|\.pkrvars\.hcl)$
require_serial: true

- id: tflint
Expand Down
2 changes: 1 addition & 1 deletion hooks/packer-validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ VALIDATE_ERROR=0
for dir in $(echo "$@" | xargs -n1 dirname | sort -u | uniq); do
echo "--> Running 'packer validate -syntax-only' in directory '$dir'"
pushd "$dir" >/dev/null
packer validate -syntax-only || VALIDATE_ERROR=$?
packer validate -syntax-only . || VALIDATE_ERROR=$?
popd >/dev/null
done

Expand Down

0 comments on commit 3544d29

Please sign in to comment.