Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide PACKER_CONFIG_DIR for packer checks #19

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions hooks/packer_fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ if command -v packer &>/dev/null; then
PACKER_EXEC="packer"
elif command -v docker &>/dev/null; then
docker pull $IMAGE_URL
PACKER_EXEC="docker run --rm -v $(pwd):/data ${IMAGE_URL} \
packer init . && packer"
PACKER_EXEC="docker run --rm \
-v $(pwd):/data \
-e PACKER_CONFIG_DIR=/data \
${IMAGE_URL} packer"
else
echo "Packer not found"
exit 1
Expand All @@ -22,6 +24,7 @@ else
for i in "$@"; do
pushd "$(dirname "$i")" &>/dev/null
echo "Formatting $i ..."
$PACKER_EXEC init "$(basename "$i")"
$PACKER_EXEC fmt -write=false "$(basename "$i")"
popd &>/dev/null
done
Expand Down
7 changes: 5 additions & 2 deletions hooks/packer_validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ if command -v packer &>/dev/null; then
PACKER_EXEC="packer"
elif command -v docker &>/dev/null; then
docker pull $IMAGE_URL
PACKER_EXEC="docker run --rm -v $(pwd):/data ${IMAGE_URL} \
packer init . && packer"
PACKER_EXEC="docker run --rm \
-v $(pwd):/data \
-e PACKER_CONFIG_DIR=/data \
${IMAGE_URL} packer"
else
echo "Packer not found"
exit 1
Expand All @@ -22,6 +24,7 @@ else
for i in "$@"; do
pushd "$(dirname "$i")" &>/dev/null
echo "Validating $i ..."
$PACKER_EXEC init "$(basename "$i")"
$PACKER_EXEC validate "$(basename "$i")"
popd &>/dev/null
done
Expand Down