fix: remove duplicated code in image-util.sh due to merge conflict

Signed-off-by: Ernest Wong <chuwon@microsoft.com>
This commit is contained in:
Ernest Wong 2021-02-05 14:12:25 -08:00
parent 036cab71a6
commit 5a559e48f8
No known key found for this signature in database
GPG Key ID: 2FA4704546158B3F
2 changed files with 29 additions and 43 deletions

View File

@ -17,7 +17,7 @@ steps:
- TAG=$_GIT_TAG - TAG=$_GIT_TAG
- BASE_REF=$_PULL_BASE_REF - BASE_REF=$_PULL_BASE_REF
- WHAT=$_WHAT - WHAT=$_WHAT
- REGISTRY=gcr.io/k8s-staging-e2e-test-images - REGISTRY=$_REGISTRY
# The default cloudbuild has HOME=/builder/home and docker buildx is in /root/.docker/cli-plugins/docker-buildx # The default cloudbuild has HOME=/builder/home and docker buildx is in /root/.docker/cli-plugins/docker-buildx
# We need to set the HOME to /root explicitly since we're using docker buildx # We need to set the HOME to /root explicitly since we're using docker buildx
- HOME=/root - HOME=/root
@ -40,5 +40,7 @@ substitutions:
# _PULL_BASE_REF will contain the ref that was pushed to to trigger this build - # _PULL_BASE_REF will contain the ref that was pushed to to trigger this build -
# a branch like 'master' or 'release-0.2', or a tag like 'v0.2'. # a branch like 'master' or 'release-0.2', or a tag like 'v0.2'.
_PULL_BASE_REF: 'master' _PULL_BASE_REF: 'master'
# _REGISTRY will contain the staging registry.
_REGISTRY: 'gcr.io/k8s-staging-e2e-test-images'
# _WHAT will contain the image name to be built and published to the staging registry. # _WHAT will contain the image name to be built and published to the staging registry.
_WHAT: 'all-conformance' _WHAT: 'all-conformance'

View File

@ -18,8 +18,8 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
TASK=$1 TASK=${1}
WHAT=$2 WHAT=${2}
# docker buildx command is still experimental as of Docker 19.03.0 # docker buildx command is still experimental as of Docker 19.03.0
export DOCKER_CLI_EXPERIMENTAL="enabled" export DOCKER_CLI_EXPERIMENTAL="enabled"
@ -51,13 +51,13 @@ initWindowsOsVersions
# Returns list of all supported architectures from BASEIMAGE file # Returns list of all supported architectures from BASEIMAGE file
listOsArchs() { listOsArchs() {
image=$1 local image=${1}
cut -d "=" -f 1 "${image}"/BASEIMAGE cut -d "=" -f 1 "${image}"/BASEIMAGE
} }
splitOsArch() { splitOsArch() {
image=$1 local image=${1}
os_arch=$2 local os_arch=${2}
if [[ $os_arch =~ .*/.*/.* ]]; then if [[ $os_arch =~ .*/.*/.* ]]; then
# for Windows, we have to support both LTS and SAC channels, so we're building multiple Windows images. # for Windows, we have to support both LTS and SAC channels, so we're building multiple Windows images.
@ -88,9 +88,9 @@ getBaseImage() {
# it will build for all the supported arch list - amd64, arm, # it will build for all the supported arch list - amd64, arm,
# arm64, ppc64le, s390x # arm64, ppc64le, s390x
build() { build() {
image=$1 local image=${1}
img_folder=$1 local img_folder=${1}
output_type=$2 local output_type=${2}
docker_version_check docker_version_check
if [[ -f "${img_folder}/BASEIMAGE" ]]; then if [[ -f "${img_folder}/BASEIMAGE" ]]; then
@ -109,15 +109,6 @@ build() {
image="${alias_name}" image="${alias_name}"
fi fi
# image tag
TAG=$(<"${img_folder}/VERSION")
alias_name="$(cat "${img_folder}/ALIAS" 2>/dev/null || true)"
if [[ -n "${alias_name}" ]]; then
echo "Found an alias for '${image}'. Building / tagging image as '${alias_name}.'"
image="${alias_name}"
fi
kube::util::ensure-gnu-sed kube::util::ensure-gnu-sed
for os_arch in ${os_archs}; do for os_arch in ${os_archs}; do
@ -196,7 +187,7 @@ docker_version_check() {
# This function will push the docker images # This function will push the docker images
push() { push() {
image=$1 local image=${1}
docker_version_check docker_version_check
TAG=$(<"${image}"/VERSION) TAG=$(<"${image}"/VERSION)
@ -214,13 +205,6 @@ push() {
image="${alias_name}" image="${alias_name}"
fi fi
pushd "${image}"
alias_name="$(cat ALIAS 2>/dev/null || true)"
if [[ -n "${alias_name}" ]]; then
echo "Found an alias for '${image}'. Pushing image as '${alias_name}.'"
image="${alias_name}"
fi
kube::util::ensure-gnu-sed kube::util::ensure-gnu-sed
# reset manifest list; needed in case multiple images are being built / pushed. # reset manifest list; needed in case multiple images are being built / pushed.
@ -261,7 +245,7 @@ push() {
# This function is for building AND pushing images. Useful if ${WHAT} is "all-conformance". # This function is for building AND pushing images. Useful if ${WHAT} is "all-conformance".
# This will allow images to be pushed immediately after they've been built. # This will allow images to be pushed immediately after they've been built.
build_and_push() { build_and_push() {
image=$1 local image=${1}
build "${image}" "registry" build "${image}" "registry"
push "${image}" push "${image}"
} }