Support setting custom Nexus container name
Change-Id: I41098413b96ac08fe479167aa0f5d0c4a699ef33
Issue-ID: OOM-2605
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
diff --git a/build/build_nexus_blob.sh b/build/build_nexus_blob.sh
index 688410e..b41d6ca 100755
--- a/build/build_nexus_blob.sh
+++ b/build/build_nexus_blob.sh
@@ -2,7 +2,7 @@
# COPYRIGHT NOTICE STARTS HERE
#
-# Copyright 2018-2019 © Samsung Electronics Co., Ltd.
+# Copyright 2018-2020© Samsung Electronics Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -35,13 +35,10 @@
# Log everything
exec &> >(tee -a "${SCRIPT_LOG}")
-# Nexus repository location
+# Nexus repository properties
NEXUS_DOMAIN="nexus"
NEXUS_PORT="8081"
NEXUS_DOCKER_PORT="8082"
-NPM_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/npm-private/"
-PYPI_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/pypi-private/"
-DOCKER_REGISTRY="${NEXUS_DOMAIN}:${NEXUS_DOCKER_PORT}"
DEFAULT_REGISTRY="docker.io"
# Nexus repository credentials
@@ -97,6 +94,7 @@
-o | --output-directory use specific directory for the target blob
-p | --pypi use specific list of pypi packages to be pushed into Nexus
-rl | --resource-list-directory use specific directory with docker, pypi and npm lists
+ -c | --container-name use specific Nexus docker container name
"
exit 1
}
@@ -209,6 +207,15 @@
done
}
+validate_container_name () {
+ # Verify $1 is a valid hostname
+ if ! echo "${1}" | egrep -q "^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$";
+ then
+ echo "ERROR: ${1} is not a valid name!"
+ exit 1;
+ fi
+}
+
while [ "${1}" != "" ]; do
case ${1} in
-d | --docker ) shift
@@ -224,6 +231,10 @@
shift
NXS_NPM_LISTS+=("$(realpath ${1})")
;;
+ -c | --container-name ) shift
+ validate_container_name "${1}"
+ NEXUS_DOMAIN="${1}"
+ ;;
-o | --output-directory ) shift
NEXUS_DATA_DIR="$(realpath ${1})"
;;
@@ -256,6 +267,11 @@
exit 1
fi
+# Nexus repository locations
+NPM_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/npm-private/"
+PYPI_REGISTRY="http://${NEXUS_DOMAIN}:${NEXUS_PORT}/repository/pypi-private/"
+DOCKER_REGISTRY="${NEXUS_DOMAIN}:${NEXUS_DOCKER_PORT}"
+
# Setup directories with resources for docker, npm and pypi
NXS_SRC_DOCKER_IMG_DIR="${DATA_DIR}/offline_data/docker_images_for_nexus"
NXS_SRC_NPM_DIR="${DATA_DIR}/offline_data/npm_tar"