-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(docker): properly handle string values again (#564)
Fixes the new `docker.sh` logic to properly support string values again. Adds a test for the `get_image_field` function and changes `docker.sh` to support being tested (albeit a little hackily). Adds a `yaml_get_field` function that strips `null` for an empty string to be easier to work with in Bash. Adds tests for the new `yaml_get_field` function and behaviour. [DT-3821]
- Loading branch information
1 parent
b96f4c0
commit 5e5ab4a
Showing
5 changed files
with
137 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
# Tests docker.sh functions. | ||
|
||
# No -e because we want to handle errors to make them | ||
# obvious. | ||
set -uo pipefail | ||
|
||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | ||
|
||
export TESTING_DO_NOT_BUILD=1 | ||
# shellcheck source=docker.sh | ||
source "${DIR}/docker.sh" | ||
|
||
test_get_image_field() { | ||
local testdata="$DIR/testdata" | ||
|
||
echo "Should be able to get a string value" | ||
buildContextTest=$(get_image_field "default" "buildContext" "string" "$testdata/test.yaml") | ||
if [[ $buildContextTest != "helloWorld" ]]; then | ||
echo "Expected buildContext to be 'helloWorld', got '$buildContextTest'" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo "Should be able to get an array value" | ||
mapfile -t secretsTest < <(get_image_field "default" "secrets" "array" "$testdata/test.yaml") | ||
if [[ ${secretsTest[*]} != "hello world" ]]; then | ||
echo "Unexpected secrets value, got '${secretsTest[*]}'" >&2 | ||
exit 1 | ||
fi | ||
} | ||
|
||
test_get_image_field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
default: | ||
buildContext: helloWorld | ||
secrets: | ||
- hello | ||
- world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters