Skip to content

Commit

Permalink
Simplify passing of stage and version to modcmd
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Evich <[email protected]>
  • Loading branch information
cevich committed Sep 29, 2022
1 parent 6c4e52e commit 8364fe9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions build-push/bin/main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 \
Expand All @@ -166,7 +168,7 @@ fi
build-push.sh \
$_DRNOPUSH \
--arches=$ARCHES \
--modcmd="tag_version.sh $STAGE_NAME" \
--modcmd="$modcmdarg" \
$REPO_FQIN \
./$CTX_SUB \
$lblargs \
Expand Down
9 changes: 6 additions & 3 deletions build-push/bin/tag_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8364fe9

Please sign in to comment.