fix shellcheck failure in test/image/image-util.sh

This commit is contained in:
toyoda 2019-07-30 10:44:42 +09:00
parent 07e0cce409
commit 5563e20a56
2 changed files with 8 additions and 9 deletions

View File

@ -15,4 +15,3 @@
./cluster/pre-existing/util.sh ./cluster/pre-existing/util.sh
./cluster/validate-cluster.sh ./cluster/validate-cluster.sh
./hack/lib/test.sh ./hack/lib/test.sh
./test/images/image-util.sh

View File

@ -35,7 +35,7 @@ listArchs() {
# Returns baseimage need to used in Dockerfile for any given architecture # Returns baseimage need to used in Dockerfile for any given architecture
getBaseImage() { getBaseImage() {
arch=$1 arch=$1
echo $(grep "${arch}=" BASEIMAGE | cut -d= -f2) grep "${arch}=" BASEIMAGE | cut -d= -f2
} }
# This function will build test image for all the architectures # This function will build test image for all the architectures
@ -46,7 +46,7 @@ build() {
if [[ -f ${IMAGE}/BASEIMAGE ]]; then if [[ -f ${IMAGE}/BASEIMAGE ]]; then
archs=$(listArchs) archs=$(listArchs)
else else
archs=${!QEMUARCHS[@]} archs=${!QEMUARCHS[*]}
fi fi
kube::util::ensure-gnu-sed kube::util::ensure-gnu-sed
@ -77,7 +77,7 @@ build() {
fi fi
# copy the qemu-*-static binary to docker image to build the multi architecture image on x86 platform # copy the qemu-*-static binary to docker image to build the multi architecture image on x86 platform
if [[ $(grep "CROSS_BUILD_" Dockerfile) ]]; then if grep -q "CROSS_BUILD_" Dockerfile; then
if [[ "${arch}" == "amd64" ]]; then if [[ "${arch}" == "amd64" ]]; then
${SED} -i "/CROSS_BUILD_/d" Dockerfile ${SED} -i "/CROSS_BUILD_/d" Dockerfile
else else
@ -119,7 +119,7 @@ push() {
if [[ -f ${IMAGE}/BASEIMAGE ]]; then if [[ -f ${IMAGE}/BASEIMAGE ]]; then
archs=$(listArchs) archs=$(listArchs)
else else
archs=${!QEMUARCHS[@]} archs=${!QEMUARCHS[*]}
fi fi
for arch in ${archs}; do for arch in ${archs}; do
docker push "${REGISTRY}/${IMAGE}-${arch}:${TAG}" docker push "${REGISTRY}/${IMAGE}-${arch}:${TAG}"
@ -130,8 +130,8 @@ push() {
# The manifest command is still experimental as of Docker 18.09.2 # The manifest command is still experimental as of Docker 18.09.2
export DOCKER_CLI_EXPERIMENTAL="enabled" export DOCKER_CLI_EXPERIMENTAL="enabled"
# Make archs list into image manifest. Eg: 'amd64 ppc64le' to '${REGISTRY}/${IMAGE}-amd64:${TAG} ${REGISTRY}/${IMAGE}-ppc64le:${TAG}' # Make archs list into image manifest. Eg: 'amd64 ppc64le' to '${REGISTRY}/${IMAGE}-amd64:${TAG} ${REGISTRY}/${IMAGE}-ppc64le:${TAG}'
manifest=$(echo "$archs" | ${SED} -e "s~[^ ]*~$REGISTRY\/$IMAGE\-&:$TAG~g") while IFS='' read -r line; do manifest+=("$line"); done < <(echo "$archs" | ${SED} -e "s~[^ ]*~$REGISTRY\/$IMAGE\-&:$TAG~g")
docker manifest create --amend "${REGISTRY}/${IMAGE}:${TAG}" ${manifest} docker manifest create --amend "${REGISTRY}/${IMAGE}:${TAG}" "${manifest[@]}"
for arch in ${archs}; do for arch in ${archs}; do
docker manifest annotate --arch "${arch}" "${REGISTRY}/${IMAGE}:${TAG}" "${REGISTRY}/${IMAGE}-${arch}:${TAG}" docker manifest annotate --arch "${arch}" "${REGISTRY}/${IMAGE}:${TAG}" "${REGISTRY}/${IMAGE}-${arch}:${TAG}"
done done
@ -141,10 +141,10 @@ push() {
# This function is for building the go code # This function is for building the go code
bin() { bin() {
local arch_prefix="" local arch_prefix=""
if [[ "${ARCH}" == "arm" ]]; then if [[ "${ARCH:-}" == "arm" ]]; then
arch_prefix="GOARM=${GOARM:-7}" arch_prefix="GOARM=${GOARM:-7}"
fi fi
for SRC in $@; for SRC in "$@";
do do
docker run --rm -it -v "${TARGET}:${TARGET}:Z" -v "${KUBE_ROOT}":/go/src/k8s.io/kubernetes:Z \ docker run --rm -it -v "${TARGET}:${TARGET}:Z" -v "${KUBE_ROOT}":/go/src/k8s.io/kubernetes:Z \
golang:"${GOLANG_VERSION}" \ golang:"${GOLANG_VERSION}" \