From 05cfbecab99a738745e4fe665eae62ace591feae Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Fri, 16 Jul 2021 15:29:46 +0000 Subject: [PATCH] test images: Adds image labels by default Adds the "image_version", "commit_id", "git_url" to the image labels. --- test/images/busybox/Dockerfile | 2 -- test/images/busybox/Dockerfile_windows | 1 - test/images/glusterdynamic-provisioner/Dockerfile | 2 -- test/images/httpd-new/Dockerfile | 2 -- test/images/httpd-new/Dockerfile_windows | 1 - test/images/httpd/Dockerfile | 2 -- test/images/httpd/Dockerfile_windows | 1 - test/images/image-util.sh | 5 ++++- test/images/nginx-new/Dockerfile | 2 -- test/images/nginx-new/Dockerfile_windows | 1 - test/images/nginx/Dockerfile | 2 -- test/images/nginx/Dockerfile_windows | 1 - test/images/perl/Dockerfile | 2 -- test/images/windows-nanoserver/Dockerfile | 2 -- 14 files changed, 4 insertions(+), 22 deletions(-) diff --git a/test/images/busybox/Dockerfile b/test/images/busybox/Dockerfile index 606b94b0380..09a6978c0b5 100644 --- a/test/images/busybox/Dockerfile +++ b/test/images/busybox/Dockerfile @@ -15,5 +15,3 @@ # NOTE(claudiub): Noop. We're just mirroring the image to staging. ARG BASEIMAGE FROM $BASEIMAGE - -LABEL image_version="1.29-1" diff --git a/test/images/busybox/Dockerfile_windows b/test/images/busybox/Dockerfile_windows index 794087320fa..8fe5e85992c 100644 --- a/test/images/busybox/Dockerfile_windows +++ b/test/images/busybox/Dockerfile_windows @@ -92,5 +92,4 @@ ENV PATH="C:\dig\;C:\bin;C:\curl;C:\Windows\System32;C:\Windows;C:\Program Files # Persist %PSCORE% ENV variable for user convenience PSCORE="C:\Program Files\PowerShell\pwsh.exe" -LABEL image_version="1.29-1" ENTRYPOINT ["cmd.exe", "/s", "/c"] diff --git a/test/images/glusterdynamic-provisioner/Dockerfile b/test/images/glusterdynamic-provisioner/Dockerfile index d44092ad096..3983b7c4f24 100644 --- a/test/images/glusterdynamic-provisioner/Dockerfile +++ b/test/images/glusterdynamic-provisioner/Dockerfile @@ -15,5 +15,3 @@ # NOTE(claudiub): Noop. We're just mirroring the image to staging. ARG BASEIMAGE FROM $BASEIMAGE - -LABEL image_version="v1.0" diff --git a/test/images/httpd-new/Dockerfile b/test/images/httpd-new/Dockerfile index a71d50e0c6f..09a6978c0b5 100644 --- a/test/images/httpd-new/Dockerfile +++ b/test/images/httpd-new/Dockerfile @@ -15,5 +15,3 @@ # NOTE(claudiub): Noop. We're just mirroring the image to staging. ARG BASEIMAGE FROM $BASEIMAGE - -LABEL image_version="2.4.39-1" diff --git a/test/images/httpd-new/Dockerfile_windows b/test/images/httpd-new/Dockerfile_windows index 8f1a46d1d34..57d35bf8673 100644 --- a/test/images/httpd-new/Dockerfile_windows +++ b/test/images/httpd-new/Dockerfile_windows @@ -43,5 +43,4 @@ ENV PATH="C:\dig;C:\bin;C:\curl;C:\Windows\System32;C:\Windows;C:\Program Files\ USER ContainerAdministrator EXPOSE 80 -LABEL image_version="2.4.39-1" ENTRYPOINT ["C:/usr/local/apache2/bin/httpd.exe"] diff --git a/test/images/httpd/Dockerfile b/test/images/httpd/Dockerfile index 2ab6032ce42..09a6978c0b5 100644 --- a/test/images/httpd/Dockerfile +++ b/test/images/httpd/Dockerfile @@ -15,5 +15,3 @@ # NOTE(claudiub): Noop. We're just mirroring the image to staging. ARG BASEIMAGE FROM $BASEIMAGE - -LABEL image_version="2.4.38-1" diff --git a/test/images/httpd/Dockerfile_windows b/test/images/httpd/Dockerfile_windows index f973cb8bf89..b7ebb8d9bd3 100644 --- a/test/images/httpd/Dockerfile_windows +++ b/test/images/httpd/Dockerfile_windows @@ -43,5 +43,4 @@ ENV PATH="C:\dig;C:\bin;C:\curl;C:\Windows\System32;C:\Windows;C:\Program Files\ USER ContainerAdministrator EXPOSE 80 -LABEL image_version="2.4.39-1" ENTRYPOINT ["C:/usr/local/apache2/bin/httpd.exe"] diff --git a/test/images/image-util.sh b/test/images/image-util.sh index 3d4cf5311b7..c89c52e645d 100755 --- a/test/images/image-util.sh +++ b/test/images/image-util.sh @@ -36,6 +36,7 @@ source "${KUBE_ROOT}/hack/lib/util.sh" # Mapping of go ARCH to actual architectures shipped part of multiarch/qemu-user-static project declare -A QEMUARCHS=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" ["ppc64le"]="ppc64le" ["s390x"]="s390x" ) +GIT_COMMIT_ID=$(git log -1 --format=%h) windows_os_versions=(1809 1903 1909 2004 20H2) declare -A WINDOWS_OS_VERSIONS_MAP @@ -182,7 +183,9 @@ build() { docker buildx build --progress=plain --no-cache --pull --output=type="${output_type}" --platform "${os_name}/${arch}" \ --build-arg BASEIMAGE="${base_image}" --build-arg REGISTRY="${REGISTRY}" --build-arg OS_VERSION="${os_version}" \ - -t "${REGISTRY}/${image}:${TAG}-${suffix}" -f "${dockerfile_name}" . + -t "${REGISTRY}/${image}:${TAG}-${suffix}" -f "${dockerfile_name}" \ + --label "image_version=${TAG}" --label "commit_id=${GIT_COMMIT_ID}" \ + --label "git_url=https://github.com/kubernetes/kubernetes/tree/${GIT_COMMIT_ID}/test/images/${img_folder}" . popd done diff --git a/test/images/nginx-new/Dockerfile b/test/images/nginx-new/Dockerfile index b5dac6276db..3983b7c4f24 100644 --- a/test/images/nginx-new/Dockerfile +++ b/test/images/nginx-new/Dockerfile @@ -15,5 +15,3 @@ # NOTE(claudiub): Noop. We're just mirroring the image to staging. ARG BASEIMAGE FROM $BASEIMAGE - -LABEL image_version="1.15-1" diff --git a/test/images/nginx-new/Dockerfile_windows b/test/images/nginx-new/Dockerfile_windows index c0d48ac98aa..0ba3744716c 100644 --- a/test/images/nginx-new/Dockerfile_windows +++ b/test/images/nginx-new/Dockerfile_windows @@ -24,5 +24,4 @@ COPY --from=nginx-source /nginx /usr/share/nginx USER ContainerAdministrator EXPOSE 80 -LABEL image_version="1.15-1" ENTRYPOINT ["/bin/sh", "-c", " cd /usr/share/nginx && ./nginx.exe"] diff --git a/test/images/nginx/Dockerfile b/test/images/nginx/Dockerfile index 9a0c8ffb425..3983b7c4f24 100644 --- a/test/images/nginx/Dockerfile +++ b/test/images/nginx/Dockerfile @@ -15,5 +15,3 @@ # NOTE(claudiub): Noop. We're just mirroring the image to staging. ARG BASEIMAGE FROM $BASEIMAGE - -LABEL image_version="1.14-1" diff --git a/test/images/nginx/Dockerfile_windows b/test/images/nginx/Dockerfile_windows index 8f65e28bc06..426df1e2569 100644 --- a/test/images/nginx/Dockerfile_windows +++ b/test/images/nginx/Dockerfile_windows @@ -24,5 +24,4 @@ COPY --from=nginx-source /nginx /usr/share/nginx USER ContainerAdministrator EXPOSE 80 -LABEL image_version="1.14-1" ENTRYPOINT ["/bin/sh", "-c", " cd /usr/share/nginx && ./nginx.exe"] diff --git a/test/images/perl/Dockerfile b/test/images/perl/Dockerfile index b87e4ec722d..3983b7c4f24 100644 --- a/test/images/perl/Dockerfile +++ b/test/images/perl/Dockerfile @@ -15,5 +15,3 @@ # NOTE(claudiub): Noop. We're just mirroring the image to staging. ARG BASEIMAGE FROM $BASEIMAGE - -LABEL image_version="5.26" diff --git a/test/images/windows-nanoserver/Dockerfile b/test/images/windows-nanoserver/Dockerfile index babebadd6a1..3983b7c4f24 100644 --- a/test/images/windows-nanoserver/Dockerfile +++ b/test/images/windows-nanoserver/Dockerfile @@ -15,5 +15,3 @@ # NOTE(claudiub): Noop. We're just mirroring the image to staging. ARG BASEIMAGE FROM $BASEIMAGE - -LABEL image_version="v1"