mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00

with docker 23.0.0, the builder defaults to Buildx which changed how multi-stage builds are done. It looks the images used during builds are no longer part of "docker images" which make the image base layer test to fail: Testing docker.io/intel/intel-deviceplugin-operator:devel base layer Error: No such object: gcr.io/distroless/static ERROR: failed to inspect gcr.io/distroless/static Therefore, we must ensure gcr.io/distroless/static is pulled before the image base layer is checked. Signed-off-by: Mikko Ylinen <mikko.ylinen@intel.com>
38 lines
1.3 KiB
Bash
Executable File
38 lines
1.3 KiB
Bash
Executable File
#!/bin/sh -e
|
|
#
|
|
# Copyright 2022 Intel Corporation.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
|
|
die () {
|
|
echo "ERROR: $*"
|
|
exit 1
|
|
}
|
|
|
|
IMG=$1
|
|
shift
|
|
|
|
if [ "$1" = 'docker' ] || [ "$1" = 'buildah' ]; then
|
|
BUILDER=$1
|
|
fi
|
|
|
|
echo "Testing $IMG base layer"
|
|
|
|
if [ -z "${BUILDER}" ] || [ "${BUILDER}" = 'docker' ] ; then
|
|
if [ -z "$(docker image ls -q gcr.io/distroless/static:latest)" ]; then
|
|
docker pull gcr.io/distroless/static:latest
|
|
fi
|
|
distroless_base=$(docker inspect --format='{{index .RootFS.Layers 0}}' "gcr.io/distroless/static") || die "failed to inspect gcr.io/distroless/static"
|
|
img_base=$(docker inspect --format='{{index .RootFS.Layers 0}}' "$IMG") || die "failed to inspect $IMG"
|
|
elif [ "${BUILDER}" = 'buildah' ] ; then
|
|
buildah images -q gcr.io/distroless/static:latest 2>/dev/null || buildah pull gcr.io/distroless/static:latest
|
|
distroless_base=$(buildah inspect --type image --format='{{index .OCIv1.RootFS.DiffIDs 0}}' "gcr.io/distroless/static") || die "failed to inspect gcr.io/distroless/static"
|
|
img_base=$(buildah inspect --type image --format='{{index .OCIv1.RootFS.DiffIDs 0}}' "$IMG") || die "failed to inspect $IMG"
|
|
else
|
|
(>&2 echo "Unknown builder ${BUILDER}")
|
|
exit 1
|
|
fi
|
|
|
|
test "${distroless_base}" = "${img_base}" || die "$IMG base layer differs from gcr.io/distroless/static"
|