From 8364fe9626594d6e41529483bbe395b26989d9c5 Mon Sep 17 00:00:00 2001 From: Chris Evich Date: Thu, 29 Sep 2022 17:46:49 -0400 Subject: [PATCH] Simplify passing of stage and version to modcmd Signed-off-by: Chris Evich --- build-push/bin/main.sh | 10 ++++++---- build-push/bin/tag_version.sh | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/build-push/bin/main.sh b/build-push/bin/main.sh index 559aa61b..614f4249 100644 --- a/build-push/bin/main.sh +++ b/build-push/bin/main.sh @@ -118,8 +118,7 @@ lblargs="\ --label=org.opencontainers.image.created=$(date -u --iso-8601=seconds)" dbg "lblargs=$lblargs" -# tag_version.sh is sensitive to this value if set -export img_cmd_version="" +modcmdarg="tag_version.sh $STAGE_NAME" # For stable images, the version number of the command is needed for tagging. if [[ "$STAGE_NAME" == "stable" ]]; then @@ -150,11 +149,14 @@ if [[ "$STAGE_NAME" == "stable" ]]; then dbg "Un-tagging $REPO_FQIN" podman untag $REPO_FQIN + # tag-version.sh expects this when STAGE_NAME=stable + modcmdarg+=" $img_cmd_version" + # Stable images get pushed to 'containers' namespace as latest & version-tagged build-push.sh \ $_DRNOPUSH \ --arches=$ARCHES \ - --modcmd="tag_version.sh $STAGE_NAME" \ + --modcmd="$modcmdarg" \ $_REG/containers/$REPO_NAME \ ./$CTX_SUB \ $lblargs \ @@ -166,7 +168,7 @@ fi build-push.sh \ $_DRNOPUSH \ --arches=$ARCHES \ - --modcmd="tag_version.sh $STAGE_NAME" \ + --modcmd="$modcmdarg" \ $REPO_FQIN \ ./$CTX_SUB \ $lblargs \ diff --git a/build-push/bin/tag_version.sh b/build-push/bin/tag_version.sh index 9f64d8d3..e3f67fde 100644 --- a/build-push/bin/tag_version.sh +++ b/build-push/bin/tag_version.sh @@ -21,10 +21,13 @@ req_env_vars SCRIPT_FILEPATH RUNTIME PLATFORMOS FQIN CONTEXT \ PUSH ARCHES REGSERVER NAMESPACE IMGNAME MODCMD STAGE_NAME="$1" # upstream, testing, or stable +VERSION="$2" # output of $version_cmd if [[ -z "$STAGE_NAME" ]]; then # Defined by common_lib.sh # shellcheck disable=SC2154 - warn "$SCRIPT_FILENAME receinved empty (optional) stage-name argument." + warn "$SCRIPT_FILENAME received empty stage-name argument (optional)." +elif [[ -z "$VERSION" ]]; then + warn "$SCRIPT_FILENAME received empty version argument (optional for STAGE_NAME != stable)." fi # shellcheck disable=SC2154 @@ -35,8 +38,8 @@ if [[ "$STAGE_NAME" == "stable" ]]; then # Confirm this value is passed in by shell env. var. since # retrieving it from the image content is beyond the scope # of this script. - req_env_vars img_cmd_version - img_cmd_version=v${img_cmd_version#v} + req_env_vars VERSION + img_cmd_version=v${VERSION#v} if egrep -q '^v[0-9]+\.[0-9]+\.[0-9]+'<<<"$img_cmd_version"; then msg "Found image command version '$img_cmd_version'" else