Skip to content

Commit

Permalink
[minor] [mascore-2417] Add support for Manage customizationList
Browse files Browse the repository at this point in the history
  • Loading branch information
padmankosalaram committed May 14, 2024
1 parent 7ba62f5 commit d6126ec
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion image/cli/mascli/functions/gitops_suite_app_config
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ function gitops_suite_app_config() {
export GIT_SSH="false"
fi

export CUSTOMIZATION_ARCHIVE_SECRET=${ACCOUNT_ID}${SECRETS_KEY_SEPERATOR}${CLUSTER_ID}${SECRETS_KEY_SEPERATOR}${MAS_INSTANCE_ID}${SECRETS_KEY_SEPERATOR}

# Set and Validate App Names
# ---------------------------------------------------------------------------
Expand All @@ -411,6 +412,10 @@ function gitops_suite_app_config() {
# Getting app spec, either default or provided
# ---------------------------------------------------------------------------


export ADDITIONAL_JINJA_PARAMS_FILE="$TEMP_DIR/additional-jinja-params.yaml"
echo "{}" > $ADDITIONAL_JINJA_PARAMS_FILE

if [ "$MAS_APP_ID" == "predict" ]; then
echo "- Configuring for Predict App"

Expand Down Expand Up @@ -457,6 +462,7 @@ function gitops_suite_app_config() {
echo
echo_h2 "Using application spec provided for $MAS_APP_ID at $MAS_APPWS_SPEC_YAML"
export MAS_APPWS_SPEC=$(cat ${MAS_APPWS_SPEC_YAML} | yq -r '.' --yaml-output)
/usr/bin/yq eval '.mas_appws_spec.settings.customizationList | to_entries | .[].value.customizationArchiveCredentials.secretName | [] + .' ${MAS_APPWS_SPEC_YAML} | /usr/bin/yq '{"CUSTOMIZATION_ARCHIVE_SECRET_NAMES": [] + .}' > $ADDITIONAL_JINJA_PARAMS_FILE
else
echo
echo_h2 "Using default application spec for $MAS_APP_ID"
Expand Down Expand Up @@ -511,7 +517,7 @@ function gitops_suite_app_config() {
/usr/bin/yq 'del(.ibm_mas_masapp_configs[] | select(.mas_app_id == "'${MAS_APP_ID}'" and .mas_workspace_id == "'${MAS_WORKSPACE_ID}'"))' $CONFIGS_FILE > $TEMP_DIR/configs.yaml

# Render the appropriate template for the config into a new file
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/masapp/ibm-mas-masapp-config.yaml.j2 | /usr/bin/yq '{"ibm_mas_masapp_configs": [] + .}' > ${TEMP_DIR}/newconfig.yaml
jinja -X .+ -d $ADDITIONAL_JINJA_PARAMS_FILE $CLI_DIR/templates/gitops/appset-configs/cluster/instance/masapp/ibm-mas-masapp-config.yaml.j2 | /usr/bin/yq '{"ibm_mas_masapp_configs": [] + .}' > ${TEMP_DIR}/newconfig.yaml

# Merge the two files
/usr/bin/yq eval-all '. as $item ireduce ({}; . *+ $item)' $TEMP_DIR/configs.yaml ${TEMP_DIR}/newconfig.yaml > $CONFIGS_FILE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ mas_workspace_id: {{ MAS_WORKSPACE_ID }}
{{ MAS_APP_SERVER_BUNDLES_COMBINED_ADD_SERVER_CONFIG | indent(2) }}
{% endif %}

{%- if CUSTOMIZATION_ARCHIVE_SECRET_NAMES is defined and CUSTOMIZATION_ARCHIVE_SECRET_NAMES !='' %}
customization_archive_secret_names:
{%- for customization_archive_secret_name in CUSTOMIZATION_ARCHIVE_SECRET_NAMES %}
- secret_name: {{ customization_archive_secret_name }}
password: <path:{{ SECRETS_PATH }}:{{ CUSTOMIZATION_ARCHIVE_SECRET }}{{ customization_archive_secret_name }}#password>
username: <path:{{ SECRETS_PATH }}:{{ CUSTOMIZATION_ARCHIVE_SECRET }}{{ customization_archive_secret_name }}#username>
{%- endfor %}
{%- endif %}

{{ MAS_APPWS_SPEC | indent(2) }}

mas_manual_cert_mgmt: {{ MAS_MANUAL_CERT_MGMT }}
Expand Down

0 comments on commit d6126ec

Please sign in to comment.