Add support for different tags for remote-cli

There may be cases where the image tags for the platform
and application side remote clients may be different. This
mostly covers post release scenarios where, we only make
changes to one of the clients.

Note: still leaving the "-t" parameter intact to not
      impact CENGN build which uses this parameter
      for remote-cli packaging.

Story: 2005312
Task: 36759
Change-Id: I35f80d174eb1c71292b457d6416c98f9bd17e4ca
Depends-On: Id6419fdb1409c57e97866de50ec1f637f4e9b71b
Signed-off-by: Stefan Dinescu <stefan.dinescu@windriver.com>
This commit is contained in:
Stefan Dinescu 2019-09-23 13:39:07 +03:00
parent 6534bb6fb3
commit 932f95c856
1 changed files with 46 additions and 15 deletions

View File

@ -16,6 +16,8 @@ if [ -z "${MY_WORKSPACE}" -o -z "${MY_REPO}" ]; then
fi
IMAGE_TAG="master-centos-stable-latest"
PLATFORM_IMAGE_TAG="${IMAGE_TAG}"
APPLICATION_IMAGE_TAG="${IMAGE_TAG}"
OUTPUT_FILE="stx-remote-cli"
VERSION="1.0"
@ -23,22 +25,33 @@ 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"
CUSTOM_IMAGE_TAG=0
COMMON_TAG=0
SPECIFIC_TAG=0
CUSTOM_PLATFORM_TAG=0
CUSTOM_APPLICATION_TAG=0
function usage {
echo "Usage:"
echo "$(basename $0) [--version <version>] [-o, --output <output_file>] [-t. --tag <image_tag>] [-h]"
echo "$(basename $0) [--version <version>] [-o, --output <output_file>] [-t. --tag <image_tag>]"
echo " [--application-tag <image_tag>] [--platform-tag <image_tag>] [-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"
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)"
}
OPTS=$(getopt -o h,o:,t: -l version:,output:,tag: -- "$@")
OPTS=$(getopt -o h,o:,t: -l version:,output:,tag:,platform-tag:,application-tag: -- "$@")
if [ $? -ne 0 ]; then
usage
exit 1
@ -65,8 +78,23 @@ while true; do
shift 2
;;
-t | --tag)
IMAGE_TAG=$2
CUSTOM_IMAGE_TAG=1
PLATFORM_IMAGE_TAG=$2
APPLICATION_IMAGE_TAG=$2
CUSTOM_PLATFORM_TAG=1
CUSTOM_APPLICATION_TAG=1
COMMON_TAG=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
shift 2
;;
*)
@ -75,6 +103,11 @@ 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}
@ -93,16 +126,14 @@ fi
cd ${BUILD_OUTPUT_PATH}
cp -r "${CLIENTS_REPO}/${REMOTE_CLI_FOLDER}" .
if [ ${CUSTOM_IMAGE_TAG} -eq 1 ]; then
# Delete the default tag file
rm -rf "${REMOTE_CLI_FOLDER}/${TAG_FILE}"
if [ $? -ne 0 ]; then
echo "Failed to delete default tag file ${BUILD_OUTPUT_PATH}/${REMOTE_CLI_FOLDER}/${TAG_FILE}" >&2
exit 1
fi
if [ ${CUSTOM_PLATFORM_TAG} -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}"
fi
# Write a new file with the custom tag
echo "export DOCKER_IMAGE_TAG=${IMAGE_TAG}" >> "${REMOTE_CLI_FOLDER}/${TAG_FILE}"
if [ ${CUSTOM_APPLICATION_TAG} -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}"
fi
# Create archive