diff --git a/asmcli/asmcli b/asmcli/asmcli index 12ac6f8c1..2bb646a01 100755 --- a/asmcli/asmcli +++ b/asmcli/asmcli @@ -4480,14 +4480,14 @@ init() { readonly APATH local REVISION_LABEL - KPT_BRANCH="${_CI_ASM_KPT_BRANCH:=main}" + KPT_BRANCH="${_CI_ASM_KPT_BRANCH:-main}" if [[ "${POINT}" == "alpha" ]]; then RELEASE="${MAJOR}.${MINOR}-alpha.${REV}" REVISION_LABEL="${_CI_REVISION_PREFIX}asm-${MAJOR}${MINOR}${POINT}" elif [[ "$(version_message)" =~ ^[0-9]+\.[0-9]+\.[0-9]+-asm\.[0-9]+\+config[0-9]+$ ]]; then RELEASE="${MAJOR}.${MINOR}.${POINT}-asm.${REV}" REVISION_LABEL="${_CI_REVISION_PREFIX}asm-${MAJOR}${MINOR}${POINT}-${REV}" - KPT_BRANCH="${_CI_ASM_KPT_BRANCH:=$(version_message)}" + KPT_BRANCH="${_CI_ASM_KPT_BRANCH:-$(version_message)}" else RELEASE="${MAJOR}.${MINOR}.${POINT}-asm.${REV}" REVISION_LABEL="${_CI_REVISION_PREFIX}asm-${MAJOR}${MINOR}${POINT}-${REV}" diff --git a/asmcli/lib/util.sh b/asmcli/lib/util.sh index 28fc20a21..3f36ff15e 100644 --- a/asmcli/lib/util.sh +++ b/asmcli/lib/util.sh @@ -367,14 +367,14 @@ init() { readonly APATH local REVISION_LABEL - KPT_BRANCH="${_CI_ASM_KPT_BRANCH:=main}" + KPT_BRANCH="${_CI_ASM_KPT_BRANCH:-main}" if [[ "${POINT}" == "alpha" ]]; then RELEASE="${MAJOR}.${MINOR}-alpha.${REV}" REVISION_LABEL="${_CI_REVISION_PREFIX}asm-${MAJOR}${MINOR}${POINT}" elif [[ "$(version_message)" =~ ^[0-9]+\.[0-9]+\.[0-9]+-asm\.[0-9]+\+config[0-9]+$ ]]; then RELEASE="${MAJOR}.${MINOR}.${POINT}-asm.${REV}" REVISION_LABEL="${_CI_REVISION_PREFIX}asm-${MAJOR}${MINOR}${POINT}-${REV}" - KPT_BRANCH="${_CI_ASM_KPT_BRANCH:=$(version_message)}" + KPT_BRANCH="${_CI_ASM_KPT_BRANCH:-$(version_message)}" else RELEASE="${MAJOR}.${MINOR}.${POINT}-asm.${REV}" REVISION_LABEL="${_CI_REVISION_PREFIX}asm-${MAJOR}${MINOR}${POINT}-${REV}" diff --git a/asmcli/tests/lib/util.bats b/asmcli/tests/lib/util.bats index 184ac566b..67430c16c 100644 --- a/asmcli/tests/lib/util.bats +++ b/asmcli/tests/lib/util.bats @@ -106,3 +106,27 @@ EOF assert_output "stable" ### [END] channel should be stable for stable GKE channel ### } + +@test "UTIL: KPT_BRANCH is set correctly for release versions" { + local TEST_VER; TEST_VER="1.1.1-asm.1+config1" + version_message() { + echo "${TEST_VER}" + } + init + + if [[ "${TEST_VER}" != "$KPT_BRANCH" ]]; then + exit 1 + fi +} + +@test "UTIL: KPT_BRANCH is set correctly for nonrelease versions" { + version_message() { + echo "1.1.1-asm.1+config1+unstable" + } + + init + + if [[ "main" != "$KPT_BRANCH" ]]; then + exit 1 + fi +}