From 43f9da596fd0900a98bad4510c33283888ae060f Mon Sep 17 00:00:00 2001 From: Ryan Drew Date: Tue, 14 Nov 2023 15:44:35 -0700 Subject: [PATCH] Fix maker-image's circular build dependency This commit adjusts `scripts/build-image.sh` to avoid attempting to run the maker-image while trying to build the maker-image. If a user is attempting to build the maker-image and it is detected that the build is running outside of the maker-image, then an attempt to run the maker-image will not be made. Users will have to ensure that local versions of the required tools are available. The build-image.sh script will attempt to run crane within the maker-image, in order to pull information about the target build image. If the user is trying to build the maker-image, and a pre-existing maker-image is not available, for instance if quay.io is down, then the script will be unable to build a new maker-image. In this case, the user is not expected to have a local copy of crane that the script can use. Signed-off-by: Ryan Drew --- scripts/build-image.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/build-image.sh b/scripts/build-image.sh index 51fbf956..bcde868f 100755 --- a/scripts/build-image.sh +++ b/scripts/build-image.sh @@ -61,7 +61,8 @@ for registry in "${registries[@]}" ; do done check_image_tag() { - if [ -n "${MAKER_CONTAINER+x}" ] ; then + if [ -n "${MAKER_CONTAINER+x}" ] || [ "${image_name}" == "image-maker" ] ; then + which crane || (echo "WARNING: crane expected but not found, unable to check if image tag exists" ; return 1) crane digest "${1}" || (echo "error: crane returned $?" ; return 1) else # unlike with other utility scripts we don't want to self-re-exec inside the container, as native `docker buildx` is preferred