Skip to content

Commit 30998ef

Browse files
joshjmsivanvc
andcommitted
Change IMAGE variable to TEST_IMAGE
Partial backport of #19305 Refactor scripts/test_images.sh * Wrap script in functions, add a main function, and call them from it. * Make environment variables local inside the function scope to avoid unexpected behaviors by the running environment-supplied variables. * Fix the typo in the "REPOSITORY" environment variable. * Rename the input "IMAGE" to "TEST_IMAGE" to avoid clashing with the environment variable from the Prow infrastructure. Co-authored-by: ivanvc <[email protected]> Signed-off-by: joshjms <[email protected]>
1 parent c9478cc commit 30998ef

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

scripts/test_images.sh

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ source ./scripts/test_lib.sh
88

99
function startContainer {
1010
# run docker in the background
11-
docker run -d --rm --name "${RUN_NAME}" "${IMAGE}"
11+
docker run -d --rm --name "${RUN_NAME}" "${TEST_IMAGE}"
1212

1313
# wait for etcd daemon to bootstrap
1414
sleep 5
1515
}
1616

1717
function runVersionCheck {
18-
Out=$(docker run --rm "${IMAGE}" "${@}")
18+
Out=$(docker run --rm "${TEST_IMAGE}" "${@}")
1919
foundVersion=$(echo "$Out" | head -1 | rev | cut -d" " -f 1 | rev )
2020
if [[ "${foundVersion}" != "${VERSION}" ]]; then
2121
echo "error: Invalid Version. Got $foundVersion, expected $VERSION. Error: $Out"
@@ -50,15 +50,15 @@ else
5050
echo "Terminating test, VERSION not supplied"
5151
exit 1
5252
fi
53-
IMAGE=${IMAGE:-"${REPOSITARY}:${TAG}"}
53+
TEST_IMAGE=${TEST_IMAGE:-"${REPOSITARY}:${TAG}"}
5454

5555
# ETCD related values
5656
RUN_NAME="test_etcd"
5757
KEY="foo"
5858
VALUE="bar"
5959

60-
if [[ "$(docker images -q "${IMAGE}" 2> /dev/null)" == "" ]]; then
61-
echo "${IMAGE} not present locally"
60+
if [[ "$(docker images -q "${TEST_IMAGE}" 2> /dev/null)" == "" ]]; then
61+
echo "${TEST_IMAGE} not present locally"
6262
exit 1
6363
fi
6464

0 commit comments

Comments
 (0)