Skip to content

Commit d2f634f

Browse files
fix(build-container-image): Don't quote build args (#78)
Co-authored-by: Nick <[email protected]>
1 parent 6060500 commit d2f634f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22

33
# Splits comma-separated values, prepends them with --build-arg, and prints
4-
# them out separated by newlines.
5-
echo "$1" | awk '{ split($0, args, ","); for (i in args) { printf "--build-arg \"%s\" ", args[i] }}'
4+
# them out. Variable values MUST mot contain any whitespace as following commands
5+
# will break.
6+
echo "$1" | awk '{ split($0, args, ","); for (i in args) { printf "--build-arg %s ", args[i] }}'

build-container-image/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ All subsequent tasks must use this value to ensure consistency.
2121
- `image-index-manifest-tag` (required, eg: `3.4.1-stackable0.0.0-dev`)
2222
- `container-file` (defaults to `Dockerfile`)
2323
- `build-context` (defaults to `.`)
24-
- `build-arguments`
24+
- `build-arguments`: MUST not contain any whitespace
2525

2626
### Outputs
2727

build-container-image/action.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ inputs:
1919
default: .
2020
build-arguments:
2121
description: |
22-
A comma-separated list of KEY=VALUE pairs provided as build arguments
22+
A comma-separated list of KEY=VALUE pairs provided as build arguments.
23+
MUST not contain any whitespace.
2324
outputs:
2425
image-repository-uri:
2526
description: |
@@ -53,6 +54,12 @@ runs:
5354
run: |
5455
set -euo pipefail
5556
57+
# Validate that the build arguments input doesn't contain any whitespaces
58+
if echo "$BUILD_ARGUMENTS" | grep '[[:space:]]'; then
59+
>&2 echo "Build arguments MUST not contain any whitespace."
60+
exit 1
61+
fi
62+
5663
DOCKER_BUILD_ARGUMENTS=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_build_arguments.sh" "$BUILD_ARGUMENTS")
5764
5865
IMAGE_ARCH=$("$GITHUB_ACTION_PATH/../.scripts/actions/get_architecture.sh")
@@ -75,7 +82,7 @@ runs:
7582
--tag "${IMAGE_MANIFEST_URI}" \
7683
--load \
7784
$DOCKER_BUILD_ARGUMENTS \
78-
"${BUILD_CONTEXT}"
85+
"$BUILD_CONTEXT"
7986
echo "::endgroup::"
8087
8188
echo "::group::docker images"

0 commit comments

Comments
 (0)