summaryrefslogtreecommitdiff
path: root/contrib/imgprune
diff options
context:
space:
mode:
authorChris Evich <cevich@redhat.com>2019-08-28 11:58:32 -0400
committerChris Evich <cevich@redhat.com>2019-08-30 09:46:43 -0400
commit56f11b1016f90d73421fa71ee8a726d2d83c9349 (patch)
tree1526cb051fc84c596d67fa229dfa5e9b0eac7425 /contrib/imgprune
parent704c4c171f2e038477e1f30fe36d540f348775fc (diff)
downloadpodman-56f11b1016f90d73421fa71ee8a726d2d83c9349.tar.gz
podman-56f11b1016f90d73421fa71ee8a726d2d83c9349.tar.bz2
podman-56f11b1016f90d73421fa71ee8a726d2d83c9349.zip
Cirrus: Load base-image names indirectly
Rather than hard-coding all four base-image env. var name, load the values based on the shared variable name suffix. Thanks to Ed Santiago <santiago@redhat.com> for the suggestion. Signed-off-by: Chris Evich <cevich@redhat.com>
Diffstat (limited to 'contrib/imgprune')
-rwxr-xr-xcontrib/imgprune/entrypoint.sh14
1 files changed, 9 insertions, 5 deletions
diff --git a/contrib/imgprune/entrypoint.sh b/contrib/imgprune/entrypoint.sh
index 829e9938e..b0f006332 100755
--- a/contrib/imgprune/entrypoint.sh
+++ b/contrib/imgprune/entrypoint.sh
@@ -6,13 +6,17 @@ source /usr/local/bin/lib_entrypoint.sh
req_env_var GCPJSON GCPNAME GCPPROJECT IMGNAMES
-BASE_IMAGES=""
-# When executing under Cirrus-CI, have access to current source
-if [[ "$CI" == "true" ]] && [[ -r "$CIRRUS_WORKING_DIR/$SCRIPT_BASE" ]]
+unset BASE_IMAGES
+# When executing under Cirrus-CI, script have access to current source
+LIB="$CIRRUS_WORKING_DIR/$SCRIPT_BASE/lib.sh"
+if [[ "$CI" == "true" ]] && [[ -r "$LIB" ]]
then
# Avoid importing anything that might conflict
- eval "$(egrep -sh '^export .+BASE_IMAGE=' < $CIRRUS_WORKING_DIR/$SCRIPT_BASE/lib.sh)"
- BASE_IMAGES="$UBUNTU_BASE_IMAGE $PRIOR_UBUNTU_BASE_IMAGE $FEDORA_BASE_IMAGE $PRIOR_FEDORA_BASE_IMAGE"
+ for env in $(sed -ne 's/^[^#]\+_BASE_IMAGE=/img=/p' "$LIB")
+ do
+ eval $env
+ BASE_IMAGES="$BASE_IMAGES $img"
+ done
else
# metadata labeling may have broken for some reason in the future
echo "Warning: Running outside of Cirrus-CI, very minor-risk of base-image deletion."