Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor] migrate to Jinjanator #1469

Merged
merged 11 commits into from
Feb 25, 2025
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"files": "^.secrets.baseline$",
"lines": null
},
"generated_at": "2025-02-12T12:31:53Z",
"generated_at": "2025-02-19T10:22:06Z",
"plugins_used": [
{
"name": "AWSKeyDetector"
Expand Down Expand Up @@ -424,7 +424,7 @@
"hashed_secret": "fee2d55ad9a49a95fc89abe8f414dad66704ebfd",
"is_secret": false,
"is_verified": false,
"line_number": 22,
"line_number": 7,
"type": "Secret Keyword",
"verified_result": null
}
Expand Down
4 changes: 3 additions & 1 deletion docs/examples/minimal-rbac.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ MAS_INSTANCE_ID=dev1
export SERVER=https://myocp.net
# Install the minimal RBAC for the MAS install (as OpenShift administrator)
oc login --token xxx --server=$SERVER
kustomize build rbac/install | jinja -D mas_instance_id $MAS_INSTANCE_ID | oc apply -f -
export mas_instance_id=$MAS_INSTANCE_ID
kustomize build rbac/install > rbac-install.yaml
jinjanate rbac-install.yaml | oc apply -f -

# Get the access token for the user
export INSTALL_TOKEN=$(oc -n mas-${MAS_INSTANCE_ID}-pipelines get secret mas-${MAS_INSTANCE_ID}-install-token -o jsonpath="{.data.token}" | base64 -d)
Expand Down
6 changes: 3 additions & 3 deletions image/cli/mascli/functions/gitops_bootstrap
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function gitops_bootstrap() {

# 2. Create Secret Manager secret
echo 'Create Secret Manager Backend Secret'
jinja -X .+ ${CLI_DIR}/templates/gitops/bootstrap/secret-${AVP_TYPE}.yaml.j2 | oc apply -f -
jinjanate_commmon ${CLI_DIR}/templates/gitops/bootstrap/secret-${AVP_TYPE}.yaml.j2 | oc apply -f -

# 3. Create repo server SA
echo 'Create ArgoCD repo server service account'
Expand All @@ -204,11 +204,11 @@ function gitops_bootstrap() {
oc wait --for=jsonpath='{.status.applicationController}'=Running argocd/openshift-gitops -n openshift-gitops --timeout=30m

# 6. Add the GitHub PAT secret (used to authenticate to your environment repository, which is assumed to be private)
jinja -X .+ ${CLI_DIR}/templates/gitops/bootstrap/secret-github.yaml.j2 | oc apply -f -
jinjanate_commmon ${CLI_DIR}/templates/gitops/bootstrap/secret-github.yaml.j2 | oc apply -f -

# 7. Add the root project and application
oc apply -f ${CLI_DIR}/templates/gitops/bootstrap/mas-appproject.yaml
jinja -X .+ ${CLI_DIR}/templates/gitops/bootstrap/root-application.yaml.j2 | oc apply -f -
jinjanate_commmon ${CLI_DIR}/templates/gitops/bootstrap/root-application.yaml.j2 | oc apply -f -

# 8. Patch openshift-marketplace and kube-system to allow GitOps to manage resources in the namespace
echo 'Patch standard namespaces to enable GitOps management'
Expand Down
2 changes: 1 addition & 1 deletion image/cli/mascli/functions/gitops_cis_compliance
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function gitops_cis_compliance() {
echo
echo_h2 "Generating Argo Applications"
echo "- IBM Cis Compliance"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/cis-compliance.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/cis-compliance.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/cis-compliance.yaml.j2 ${GITOPS_CLUSTER_DIR}/cis-compliance.yaml

# Commit and push to github target repo
# ---------------------------------------------------------------------------
Expand Down
26 changes: 13 additions & 13 deletions image/cli/mascli/functions/gitops_cluster
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ function gitops_cluster() {
export ICR_AUTH_TOKEN=$(echo -n $ICR_USERNAME:$ICR_PASSWORD | base64 -w 0)

echo "- Generate image pull secret"
jinja -X .+ $CLI_DIR/templates/gitops/ibm-entitlement-with-artifactory.json.j2 -o ${GITOPS_CLUSTER_DIR}/ibm-entitlement-with-artifactory.json
jinjanate_commmon $CLI_DIR/templates/gitops/ibm-entitlement-with-artifactory.json.j2 ${GITOPS_CLUSTER_DIR}/ibm-entitlement-with-artifactory.json

IBM_ENTITLEMENT_WITH_ARTIFACTORY=${GITOPS_CLUSTER_DIR}/ibm-entitlement-with-artifactory.json
IBM_ENTITLEMENT_WITH_ARTIFACTORY=$(cat $IBM_ENTITLEMENT_WITH_ARTIFACTORY)
Expand Down Expand Up @@ -620,63 +620,63 @@ function gitops_cluster() {
echo_h2 "Generating Argo Applications"

echo "- Base Config"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/ibm-mas-cluster-base.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/ibm-mas-cluster-base.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/ibm-mas-cluster-base.yaml.j2 ${GITOPS_CLUSTER_DIR}/ibm-mas-cluster-base.yaml

echo "- IBM Operator Catalog"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/ibm-operator-catalog.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/ibm-operator-catalog.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/ibm-operator-catalog.yaml.j2 ${GITOPS_CLUSTER_DIR}/ibm-operator-catalog.yaml

echo "- Redhat Cert Manager"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/redhat-cert-manager.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/redhat-cert-manager.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/redhat-cert-manager.yaml.j2 ${GITOPS_CLUSTER_DIR}/redhat-cert-manager.yaml

if [[ "$INSTALL_SELENIUM_GRID" == "true" ]]; then
echo "- Selenium Grid"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/selenium-grid.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/selenium-grid.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/selenium-grid.yaml.j2 ${GITOPS_CLUSTER_DIR}/selenium-grid.yaml
fi

if [[ "$CLUSTER_PROMOTION" == "true" ]]; then
ESCAPED_CLUSTER_VALUES=${CLUSTER_PROMOTION_CLUSTER_VALUES//\"/\\\"}
export ESCAPED_CLUSTER_VALUES=${ESCAPED_CLUSTER_VALUES//$'\n'/\\n}
echo "- Cluster Promotion"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/cluster-promotion.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/cluster-promotion.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/cluster-promotion.yaml.j2 ${GITOPS_CLUSTER_DIR}/cluster-promotion.yaml
fi

if [[ -n "$CUSTOM_SA_NAMESPACE" ]]; then
echo "- Custom Cluster Service Accounts"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/custom-sa.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/custom-sa.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/custom-sa.yaml.j2 ${GITOPS_CLUSTER_DIR}/custom-sa.yaml
fi

if [[ -n "$DNS_PROVIDER" ]]; then
echo "- IBM CIS Cert Manager"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/ibm-cis-cert-manager.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/ibm-cis-cert-manager.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/phase1/ibm-cis-cert-manager.yaml.j2 ${GITOPS_CLUSTER_DIR}/ibm-cis-cert-manager.yaml
fi

if [[ "$INSTALL_GROUP_SYNC_OPERATOR" == "true" ]]; then
echo "- Group Sync Operator"
sm_verify_secret_exists $SECRET_NAME_ISV_CLIENT "client_secret,client_id"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/group-sync-operator.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/group-sync-operator.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/group-sync-operator.yaml.j2 ${GITOPS_CLUSTER_DIR}/group-sync-operator.yaml
fi

if [[ "$INSTALL_IBM_RBAC" == "true" ]]; then
echo "- IBM RBAC"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/ibm-rbac.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/ibm-rbac.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/ibm-rbac.yaml.j2 ${GITOPS_CLUSTER_DIR}/ibm-rbac.yaml
fi

if [[ "$INSTALL_FALCON_OPERATOR" == "true" ]]; then
echo "- CrowdStrike Falcon Operator"
sm_verify_secret_exists $SECRET_NAME_FALCON_CLIENT "client_secret,client_id"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/falcon-operator.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/falcon-operator.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/falcon-operator.yaml.j2 ${GITOPS_CLUSTER_DIR}/falcon-operator.yaml
fi

if [[ -n "$CLUSTER_LOGGING_OPERATOR_INSTALL" ]]; then
echo "- Cluster Logging Operator"
sm_verify_secret_exists $SECRET_NAME_CLOUDWATCH "aws_access_key_id,aws_secret_access_key"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/cluster-logging-operator.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/cluster-logging-operator.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/cluster-logging-operator.yaml.j2 ${GITOPS_CLUSTER_DIR}/cluster-logging-operator.yaml
fi

if [[ -n "$INSTANA_AGENT_OPERATOR_INSTALL" ]]; then
echo "- Instana Agent Operator"
sm_verify_secret_exists $SECRET_NAME_INSTANA "key"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instana-agent-operator.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/instana-agent-operator.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instana-agent-operator.yaml.j2 ${GITOPS_CLUSTER_DIR}/instana-agent-operator.yaml
fi

# Commit and push to github target repo
Expand Down
2 changes: 1 addition & 1 deletion image/cli/mascli/functions/gitops_cp4d
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ function gitops_cp4d() {
echo "- CP4D operator"

echo "Generating IBM CP4D file ${GITOPS_INSTANCE_DIR}/ibm-cp4d.yaml"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-cp4d.yaml.j2 -o ${GITOPS_INSTANCE_DIR}/ibm-cp4d.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-cp4d.yaml.j2 ${GITOPS_INSTANCE_DIR}/ibm-cp4d.yaml


# Commit and push to github target repo
Expand Down
4 changes: 2 additions & 2 deletions image/cli/mascli/functions/gitops_cp4d_service
Original file line number Diff line number Diff line change
Expand Up @@ -372,14 +372,14 @@ function gitops_cp4d_service() {

if [[ "$CPD_SERVICE_NAME" == "wsl" || "$CPD_SERVICE_NAME" == "wml" || "$CPD_SERVICE_NAME" == "spss" ]]; then
echo "Generating IBM CPD Service file ${GITOPS_INSTANCE_DIR}/ibm-cp4d-services-base.yaml"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-cp4d-services-base.yaml.j2 -o ${GITOPS_INSTANCE_DIR}/ibm-cp4d-services-base.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-cp4d-services-base.yaml.j2 ${GITOPS_INSTANCE_DIR}/ibm-cp4d-services-base.yaml
fi

echo
echo "- ${CPD_SERVICE_NAME} operator"

echo "Generating IBM CPD Service file ${GITOPS_INSTANCE_DIR}/ibm-${CPD_SERVICE_NAME}.yaml"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-${CPD_SERVICE_NAME}.yaml.j2 -o ${GITOPS_INSTANCE_DIR}/ibm-${CPD_SERVICE_NAME}.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-${CPD_SERVICE_NAME}.yaml.j2 ${GITOPS_INSTANCE_DIR}/ibm-${CPD_SERVICE_NAME}.yaml

# Commit and push to github target repo
# ---------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion image/cli/mascli/functions/gitops_db2u
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ function gitops_db2u() {
export IBM_ENTITLEMENT_KEY=$SECRET_KEY_IBM_ENTITLEMENT

echo "Generating DB2U file ${GITOPS_INSTANCE_DIR}/ibm-db2u.yaml"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-db2u.yaml.j2 -o ${GITOPS_INSTANCE_DIR}/ibm-db2u.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-db2u.yaml.j2 ${GITOPS_INSTANCE_DIR}/ibm-db2u.yaml

# Commit and push to github target repo
# ---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions image/cli/mascli/functions/gitops_db2u_database
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ DB2_WORKLOAD: '${DB2_WORKLOAD}'"

# If the file doesn't exist, create a blank one
if ! [ -f ${CONFIGS_FILE} ]; then
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/db2-databases/ibm-db2u-database-common.yaml.j2 > $CONFIGS_FILE
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/db2-databases/ibm-db2u-database-common.yaml.j2 $CONFIGS_FILE
fi

# Remove any existing config with this name
Expand All @@ -740,7 +740,7 @@ DB2_WORKLOAD: '${DB2_WORKLOAD}'"
echo -n "" > ${TEMP_DIR}/newconfig.yaml
# Render the appropriate template for the config into a new file. For standby database, it will be generated only if it is a replica task and replica is enabled.
if [[ (${IS_REPLICA_TASK} == 'false') || (${IS_REPLICA_TASK} == 'true' && ${REPLICA_DB} == 'true') ]]; then
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/db2-databases/ibm-db2u-database.yaml.j2 | yq '{"ibm_db2u_databases": [] + .}' > ${TEMP_DIR}/newconfig.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/db2-databases/ibm-db2u-database.yaml.j2 | yq '{"ibm_db2u_databases": [] + .}' > ${TEMP_DIR}/newconfig.yaml
fi

# Merge the two files
Expand Down
2 changes: 1 addition & 1 deletion image/cli/mascli/functions/gitops_dro
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function gitops_dro() {
export IBM_ENTITLEMENT_KEY=$SECRET_KEY_IBM_ENTITLEMENT

echo "Generating dro file ${GITOPS_CLUSTER_DIR}/ibm-dro.yaml"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/ibm-dro.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/ibm-dro.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/ibm-dro.yaml.j2 ${GITOPS_CLUSTER_DIR}/ibm-dro.yaml

# Commit and push to github target repo
# ---------------------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions image/cli/mascli/functions/gitops_mas_config
Original file line number Diff line number Diff line change
Expand Up @@ -839,14 +839,14 @@ function gitops_mas_config() {

# If the file doesn't exist, create a blank one
if ! [ -f ${CONFIGS_FILE} ]; then
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-config-common.yaml.j2 > $CONFIGS_FILE
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-config-common.yaml.j2 $CONFIGS_FILE
fi

# Remove any existing config with this name
yq 'del(.ibm_mas_suite_configs[] | select(.mas_config_name == "'${MAS_CONFIG_NAME}'"))' $CONFIGS_FILE > $TEMP_DIR/configs.yaml

# Render the appropriate template for the config into a new file
jinja -X .+ -d $ADDITIONAL_JINJA_PARAMS_FILE $CLI_DIR/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-${MAS_CONFIG_TYPE}-config.yaml.j2 | yq '{"ibm_mas_suite_configs": [] + .}' > ${TEMP_DIR}/newconfig.yaml
jinjanate --quiet --undefined --import-env='' $CLI_DIR/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-${MAS_CONFIG_TYPE}-config.yaml.j2 $ADDITIONAL_JINJA_PARAMS_FILE | yq '{"ibm_mas_suite_configs": [] + .}' > ${TEMP_DIR}/newconfig.yaml

# Merge the two files
yq eval-all '. as $item ireduce ({}; . *+ $item)' $TEMP_DIR/configs.yaml ${TEMP_DIR}/newconfig.yaml > $CONFIGS_FILE
Expand Down
2 changes: 1 addition & 1 deletion image/cli/mascli/functions/gitops_nvidia_gpu
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ function gitops_nvidia_gpu() {
echo "- Nvidia GPU Operator"

echo "Generating Nvidia GPU operator file ${GITOPS_CLUSTER_DIR}/nvidia-gpu-operator.yaml"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/nvidia-gpu-operator.yaml.j2 -o ${GITOPS_CLUSTER_DIR}/nvidia-gpu-operator.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/nvidia-gpu-operator.yaml.j2 ${GITOPS_CLUSTER_DIR}/nvidia-gpu-operator.yaml

# Commit and push to github target repo
# ---------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions image/cli/mascli/functions/gitops_suite
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,13 @@ function gitops_suite() {
echo_h2 "Generating Argo Project and Applications"

echo "- Base Config"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-mas-instance-base.yaml.j2 -o ${GITOPS_INSTANCE_DIR}/ibm-mas-instance-base.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-mas-instance-base.yaml.j2 ${GITOPS_INSTANCE_DIR}/ibm-mas-instance-base.yaml

echo "- IBM Suite License Service"
jinja -X .+ -d $MONGO_CONFIG_FILE $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-sls.yaml.j2 -o ${GITOPS_INSTANCE_DIR}/ibm-sls.yaml
jinjanate --quiet --undefined --import-env='' $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-sls.yaml.j2 $MONGO_CONFIG_FILE -o ${GITOPS_INSTANCE_DIR}/ibm-sls.yaml

echo "- IBM Maximo Application Suite Core Platform"
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-mas-suite.yaml.j2 -o ${GITOPS_INSTANCE_DIR}/ibm-mas-suite.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-mas-suite.yaml.j2 ${GITOPS_INSTANCE_DIR}/ibm-mas-suite.yaml


# Commit and push to github target repo
Expand Down
6 changes: 3 additions & 3 deletions image/cli/mascli/functions/gitops_suite_app_config
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ function gitops_suite_app_config() {
else
echo
echo_h2 "Using default application spec for $MAS_APP_ID"
jinja -X .+ $CLI_DIR/templates/gitops/app-ws-spec-defaults/${MAS_APP_ID}.yaml.j2 -o ${TEMP_DIR}/${MAS_APP_ID}-appws-spec.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/app-ws-spec-defaults/${MAS_APP_ID}.yaml.j2 ${TEMP_DIR}/${MAS_APP_ID}-appws-spec.yaml
export MAS_APPWS_SPEC=$(cat ${TEMP_DIR}/${MAS_APP_ID}-appws-spec.yaml | yq '.' --output-format yaml)
fi
echo
Expand Down Expand Up @@ -562,15 +562,15 @@ function gitops_suite_app_config() {

# If the file doesn't exist, create a blank one
if ! [ -f ${CONFIGS_FILE} ]; then
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/masapp/ibm-mas-masapp-config-common.yaml.j2 > $CONFIGS_FILE
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/masapp/ibm-mas-masapp-config-common.yaml.j2 $CONFIGS_FILE
fi


# Remove any existing config with this app id and workspace id
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 .+ -d $ADDITIONAL_JINJA_PARAMS_FILE $CLI_DIR/templates/gitops/appset-configs/cluster/instance/masapp/ibm-mas-masapp-config.yaml.j2 | yq '{"ibm_mas_masapp_configs": [] + .}' > ${TEMP_DIR}/newconfig.yaml
jinjanate --quiet --undefined --import-env='' $CLI_DIR/templates/gitops/appset-configs/cluster/instance/masapp/ibm-mas-masapp-config.yaml.j2 $ADDITIONAL_JINJA_PARAMS_FILE | yq '{"ibm_mas_masapp_configs": [] + .}' > ${TEMP_DIR}/newconfig.yaml

# Merge the two files
yq eval-all '. as $item ireduce ({}; . *+ $item)' $TEMP_DIR/configs.yaml ${TEMP_DIR}/newconfig.yaml > $CONFIGS_FILE
Expand Down
4 changes: 2 additions & 2 deletions image/cli/mascli/functions/gitops_suite_app_install
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ function gitops_suite_app_install() {
else
echo
echo_h2 "Using default application spec for $MAS_APP_ID"
jinja -X .+ $CLI_DIR/templates/gitops/app-spec-defaults/${MAS_APP_ID}.yaml.j2 -o ${TEMP_DIR}/${MAS_APP_ID}-app-spec.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/app-spec-defaults/${MAS_APP_ID}.yaml.j2 ${TEMP_DIR}/${MAS_APP_ID}-app-spec.yaml
export MAS_APP_SPEC=$(cat ${TEMP_DIR}/${MAS_APP_ID}-app-spec.yaml | yq '.' --output-format yaml)
fi
echo_reset_dim "MAS_APP_SPEC ............................ ${COLOR_MAGENTA}${MAS_APP_SPEC}"
Expand Down Expand Up @@ -428,7 +428,7 @@ function gitops_suite_app_install() {

echo "- IBM MAS Application Install"
CONFIG_FILE=${GITOPS_INSTANCE_DIR}/ibm-mas-masapp-${MAS_APP_ID}-install.yaml
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/masapp/ibm-mas-masapp-install.yaml.j2 -o ${CONFIG_FILE}
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/masapp/ibm-mas-masapp-install.yaml.j2 ${CONFIG_FILE}


echo_h2 "Generated configuration file (${CONFIG_FILE})"
Expand Down
4 changes: 2 additions & 2 deletions image/cli/mascli/functions/gitops_suite_workspace
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,14 @@ function gitops_suite_workspace() {

# If the file doesn't exist, create a blank one
if ! [ -f ${CONFIGS_FILE} ]; then
jinja -X .+ $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-mas-workspaces-common.yaml.j2 > $CONFIGS_FILE
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-mas-workspaces-common.yaml.j2 $CONFIGS_FILE
fi

# Remove any existing config with this name
yq 'del(.ibm_mas_workspaces[] | select(.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/ibm-mas-workspace.yaml.j2 | yq '{"ibm_mas_workspaces": [] + .}' > ${TEMP_DIR}/newconfig.yaml
jinjanate_commmon $CLI_DIR/templates/gitops/appset-configs/cluster/instance/ibm-mas-workspace.yaml.j2 | yq '{"ibm_mas_workspaces": [] + .}' > ${TEMP_DIR}/newconfig.yaml

# Merge the two files
yq eval-all '. as $item ireduce ({}; . *+ $item)' $TEMP_DIR/configs.yaml ${TEMP_DIR}/newconfig.yaml > $CONFIGS_FILE
Expand Down
14 changes: 14 additions & 0 deletions image/cli/mascli/functions/internal/utils
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,17 @@ function ocp_version_check() {
exit 1
fi
}

# Calls jinjanate with common arguments. Call jinjanate directly if this does not suit your use case.
function jinjanate_commmon() {
local template_path=$1
local output_path=$2
local filter_files=$(ls $CLI_DIR/templates/filters/*.py)
for file in $filter_files; do
local filter_params="${filter_params} --filters ${file}"
done
if [ -n "$output_path" ]; then
local output_opts="-o ${output_path}"
fi
jinjanate --quiet --undefined $filter_params $template_path $output_opts
}
Loading
Loading