Use script arguments to override metadata defaults

Historically, this build-helm-charts.sh script would rely on its
APP_NAME and APP_VERSION variables to write in the application
metadata.yaml. The APP_NAME would be used to override in build-time the
application final name [1] and the APP_VERSION would be initialized by
the internal "get_app_version" functional.

Now, after the AppFwk update on all applications Zuul jobs, the
metadata.yaml can no longer be missing neither the "app_name" or the
"app_version" keys/values [2].

So, the build-helm-charts.sh needs to be updated as follows:
  1) Stop the blind write of APP_VERSION on metadata and use this
     variable to override the metadata default value instead
  2) Use APP_NAME (cli parsed argument) to override the default metadata
     app_name, instead of only using it when the metadata is missing the
     key/value.

NOTE: Since this script is currently always used with the "--app"
argument, this change should be safe. But if "--app" is not used, the
app_name will always fallback to "stx-openstack"

[1] 31aea8e88b
[2] https://review.opendev.org/c/starlingx/openstack-armada-app/+/903781

Closes-Bug: 2050825

TEST PLAN:
PASS - Build stx-openstack helm-charts tarball
PASS - system application-upload stx-openstack.tgz
PASS - system application-apply stx-openstack

Change-Id: Ibc37e1306ba93b911a66993f5e56c8e609291c2c
Signed-off-by: Thales Elero Cervi <thaleselero.cervi@windriver.com>
This commit is contained in:
Thales Elero Cervi 2024-01-22 16:06:13 -03:00
parent 0180739dc3
commit dae3b33921
1 changed files with 14 additions and 4 deletions

View File

@ -42,7 +42,9 @@ Options:
Specify base OS (valid options: ${SUPPORTED_OS_ARGS[@]})
-a, --app NAME:
Specify the application name
Specify the application name.
When not specified will fall-back to its default value.
Default: stx-openstack
-A, --app-version-file FILENAME:
Specify the file containing version information for the helm
@ -316,10 +318,18 @@ function build_application_tarball_fluxcd {
if [ -n "${LABEL}" ]; then
APP_VERSION=${APP_VERSION}-${LABEL}
fi
if ! grep -q "^app_name:" metadata.yaml ; then
echo "app_name: ${APP_NAME}" >> metadata.yaml
if [ -z "${APP_NAME}" ] ; then
echo "No APP_NAME argument. Using metadata.yaml info instead..."
else
echo "Overriding metadata.yaml info... app_name: ${APP_NAME}"
sed -i "/^\([[:space:]]*app_name: \).*/s//\1${APP_NAME}/" metadata.yaml
fi
if [ -z "${APP_VERSION}" ] ; then
echo "No APP_VERSION argument. Using metadata.yaml info instead..."
else
echo "Overriding metadata.yaml info... app_version: ${APP_VERSION}"
sed -i "/^\([[:space:]]*app_version: \).*/s//\1${APP_VERSION}/" metadata.yaml
fi
echo "app_version: ${APP_VERSION}" >> metadata.yaml
if [ -n "${PATCH_DEPENDENCIES}" ]; then
echo "patch_dependencies:" >> metadata.yaml
for patch in ${PATCH_DEPENDENCIES[@]}; do