7dc6b23b51
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>
128 lines
3.9 KiB
Bash
Executable File
128 lines
3.9 KiB
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Copyright (c) 2019 Wind River Systems, Inc.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# This utility retrieves StarlingX remote CLI
|
|
# wrapper scripts from the REPO and packages
|
|
# them in a tarball
|
|
#
|
|
|
|
# Required environment variables
|
|
if [ -z "${MY_WORKSPACE}" -o -z "${MY_REPO}" ]; then
|
|
echo "Environment not setup for build" >&2
|
|
exit 1
|
|
fi
|
|
|
|
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"
|
|
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-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 " --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-image:,application-image: -- "$@")
|
|
if [ $? -ne 0 ]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
|
|
eval set -- "${OPTS}"
|
|
|
|
while true; do
|
|
case $1 in
|
|
--)
|
|
shift
|
|
break
|
|
;;
|
|
-h)
|
|
usage
|
|
exit 1
|
|
;;
|
|
--version)
|
|
VERSION=$2
|
|
shift 2
|
|
;;
|
|
-o | --output)
|
|
OUTPUT_FILE=$2
|
|
shift 2
|
|
;;
|
|
--platform-image)
|
|
PLATFORM_IMAGE=$2
|
|
CUSTOM_PLATFORM_IMAGE=1
|
|
shift 2
|
|
;;
|
|
--application-image)
|
|
APPLICATION_IMAGE=$2
|
|
CUSTOM_APPLICATION_IMAGE=1
|
|
shift 2
|
|
;;
|
|
*)
|
|
usage
|
|
exit 1
|
|
esac
|
|
done
|
|
|
|
if [ -d ${BUILD_OUTPUT_PATH} ]; then
|
|
# Clean the previous build
|
|
rm -rf ${BUILD_OUTPUT_PATH}
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to cleanup workspace ${BUILD_OUTPUT_PATH}" >&2
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
mkdir -p ${BUILD_OUTPUT_PATH}
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to create the workspace ${BUILD_OUTPUT_PATH}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
cd ${BUILD_OUTPUT_PATH}
|
|
cp -r "${CLIENTS_REPO}/${REMOTE_CLI_FOLDER}" .
|
|
|
|
if [ ${CUSTOM_PLATFORM_IMAGE} -eq 1 ]; then
|
|
# Replace the platform image tag
|
|
# 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_IMAGE} -eq 1 ]; then
|
|
# Replace the application image tag
|
|
sed -i "s/APPLICATION_DOCKER_IMAGE=[^ ]*/APPLICATION_DOCKER_IMAGE=\"${APPLICATION_IMAGE//\//\\/}\"/" "${REMOTE_CLI_FOLDER}/${IMAGE_FILE}"
|
|
fi
|
|
|
|
# Create archive
|
|
tar czf ${OUTPUT_FILE}-${VERSION}.tgz ${REMOTE_CLI_FOLDER}
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to create ${OUTPUT_FILE}-${VERSION}.tgz tarball" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo ""
|
|
echo "Created remote CLI tarball: ${BUILD_OUTPUT_PATH}/${OUTPUT_FILE}-${VERSION}.tgz"
|
|
echo ""
|