Support custom docker registries for remote cli

The build script for remote cli was receiving as parameters
only the desired tag for the clients docker images; the docker
images were always pulled from docker.io/starlinx.

Nowthe build script take the full link of the docker image
as parameter, so we can use any docker registry as source
for the client images.

Change-Id: Ibc4584a9401c1ff30f8e657ca27d31b35c4e94d5
Depends-On: https://review.opendev.org/#/c/713665/
Story: 2006711
Task: 39095
Signed-off-by: Stefan Dinescu <stefan.dinescu@windriver.com>
This commit is contained in:
Stefan Dinescu 2020-03-18 16:23:59 +02:00
parent 3b0e2dd4ea
commit 7dc6b23b51

View File

@ -15,43 +15,35 @@ if [ -z "${MY_WORKSPACE}" -o -z "${MY_REPO}" ]; then
exit 1
fi
IMAGE_TAG="master-centos-stable-latest"
PLATFORM_IMAGE_TAG="${IMAGE_TAG}"
APPLICATION_IMAGE_TAG="${IMAGE_TAG}"
PLATFORM_IMAGE="docker.io/starlingx/stx-platformclients:master-centos-stable-latest"
APPLICATION_IMAGE="docker.io/starlingx/stx-openstackclients:master-centos-stable-latest"
OUTPUT_FILE="stx-remote-cli"
VERSION="1.0"
CLIENTS_REPO="${MY_REPO}/stx/clients"
REMOTE_CLI_FOLDER="remote_cli"
BUILD_OUTPUT_PATH="${MY_WORKSPACE}/std/build-remote-cli"
TAG_FILE="docker_image_version.sh"
COMMON_TAG=0
SPECIFIC_TAG=0
CUSTOM_PLATFORM_TAG=0
CUSTOM_APPLICATION_TAG=0
IMAGE_FILE="docker_image_version.sh"
CUSTOM_PLATFORM_IMAGE=0
CUSTOM_APPLICATION_IMAGE=0
function usage {
echo "Usage:"
echo "$(basename $0) [--version <version>] [-o, --output <output_file>] [-t. --tag <image_tag>]"
echo " [--application-tag <image_tag>] [--platform-tag <image_tag>] [-h]"
echo " [--application-image <image>] [--platform-image <image>] [-h]"
echo "Options:"
echo " -h show help options"
echo " --version <version> specify remote CLI version"
echo " (default value is 1.0)"
echo " -o, --output <output_file> specify tarball output name"
echo " (default value is stx-remote-cli)"
echo " -t, --tag <image_tag> specify docker image tag for both platform and application."
echo " cannot be used together with --platform-tag or --application-tag options"
echo " (default value is mater-centos-stable-latest)"
echo " --platform-tag <image_tag> specify platform docker image tag."
echo " cannot be used together with --tag option"
echo " (default value is mater-centos-stable-latest)"
echo " --application-tag <image_tag> specify application docker image tag."
echo " cannot be used together with --tag option"
echo " (default value is mater-centos-stable-latest)"
echo " --platform-image <image> specify platform docker image tag."
echo " (default value is docker.io/starlingx/stx-platformclients:master-centos-stable-latest)"
echo " --application-image <image> specify application docker image."
echo " (default value is docker.io/starlingx/stx-openstackclients:master-centos-stable-latest)"
}
OPTS=$(getopt -o h,o:,t: -l version:,output:,tag:,platform-tag:,application-tag: -- "$@")
OPTS=$(getopt -o h,o:,t: -l version:,output:,tag:,platform-image:,application-image: -- "$@")
if [ $? -ne 0 ]; then
usage
exit 1
@ -77,24 +69,14 @@ while true; do
OUTPUT_FILE=$2
shift 2
;;
-t | --tag)
PLATFORM_IMAGE_TAG=$2
APPLICATION_IMAGE_TAG=$2
CUSTOM_PLATFORM_TAG=1
CUSTOM_APPLICATION_TAG=1
COMMON_TAG=1
--platform-image)
PLATFORM_IMAGE=$2
CUSTOM_PLATFORM_IMAGE=1
shift 2
;;
--platform-tag)
PLATFORM_IMAGE_TAG=$2
CUSTOM_PLATFORM_TAG=1
SPECIFIC_TAG=1
shift 2
;;
--application-tag)
APPLICATION_IMAGE_TAG=$2
CUSTOM_APPLICATION_TAG=1
SPECIFIC_TAG=1
--application-image)
APPLICATION_IMAGE=$2
CUSTOM_APPLICATION_IMAGE=1
shift 2
;;
*)
@ -103,11 +85,6 @@ while true; do
esac
done
if [[ ${SPECIFIC_TAG} -eq 1 ]] && [[ ${COMMON_TAG} -eq 1 ]]; then
echo "Cannot use both \"--tag\" and \"--application-tag\"/\"--platform-tag\" options at the same time" >&2
exit 1
fi
if [ -d ${BUILD_OUTPUT_PATH} ]; then
# Clean the previous build
rm -rf ${BUILD_OUTPUT_PATH}
@ -126,14 +103,16 @@ fi
cd ${BUILD_OUTPUT_PATH}
cp -r "${CLIENTS_REPO}/${REMOTE_CLI_FOLDER}" .
if [ ${CUSTOM_PLATFORM_TAG} -eq 1 ]; then
if [ ${CUSTOM_PLATFORM_IMAGE} -eq 1 ]; then
# Replace the platform image tag
sed -i "s/PLATFORM_DOCKER_IMAGE_TAG=[^ ]*/PLATFORM_DOCKER_IMAGE_TAG=\"${PLATFORM_IMAGE_TAG}\"/" "${REMOTE_CLI_FOLDER}/${TAG_FILE}"
# Since the full path to a docker image contains slashes, we must escape them in order to pass them to sed.
# The "${PLATFORM_IMAGE//\//\\/} takes the path and escapes all the slashes.
sed -i "s/PLATFORM_DOCKER_IMAGE=[^ ]*/PLATFORM_DOCKER_IMAGE=\"${PLATFORM_IMAGE//\//\\/}\"/" "${REMOTE_CLI_FOLDER}/${IMAGE_FILE}"
fi
if [ ${CUSTOM_APPLICATION_TAG} -eq 1 ]; then
if [ ${CUSTOM_APPLICATION_IMAGE} -eq 1 ]; then
# Replace the application image tag
sed -i "s/APPLICATION_DOCKER_IMAGE_TAG=[^ ]*/APPLICATION_DOCKER_IMAGE_TAG=\"${APPLICATION_IMAGE_TAG}\"/" "${REMOTE_CLI_FOLDER}/${TAG_FILE}"
sed -i "s/APPLICATION_DOCKER_IMAGE=[^ ]*/APPLICATION_DOCKER_IMAGE=\"${APPLICATION_IMAGE//\//\\/}\"/" "${REMOTE_CLI_FOLDER}/${IMAGE_FILE}"
fi
# Create archive