diff --git a/image/cli/mascli/functions/gitops_mas_config b/image/cli/mascli/functions/gitops_mas_config index bd8ef8e19a..9d39bff41e 100644 --- a/image/cli/mascli/functions/gitops_mas_config +++ b/image/cli/mascli/functions/gitops_mas_config @@ -74,6 +74,9 @@ SMTP Configuration (required if MAS_CONFIG_TYPE is "smtp"): --smtp-username ${COLOR_YELLOW}SMTP_USERNAME${TEXT_RESET} Username for SMTP server authentication (Optional, if secret is already set in SM) --smtp-password ${COLOR_YELLOW}SMTP_PASSWORD${TEXT_RESET} Password for SMTP server authentication (Optional, if secret is already set in SM) --mas-smtpcfg-pod-template-yaml ${COLOR_YELLOW}MAS_SMTPCFG_POD_TEMPLATE_YAML${TEXT_RESET} The location of a file containing the POD template + --smtp-disabled-templates ${COLOR_YELLOW}SMTP_DISABLED_TEMPLATES${TEXT_RESET} JSON string specifying a list of MAS Suite email templates to disable + E.g. '["UserPasswordReset", "WelcomeUsername", "WelcomePassword"]' + See https://www.ibm.com/docs/en/masv-and-l/continuous-delivery?topic=notifications-disabling-email Automatic GitHub Push: -P, --github-push ${COLOR_YELLOW}GITHUB_PUSH${TEXT_RESET} Enable automatic push to GitHub @@ -247,6 +250,9 @@ function gitops_mas_config_noninteractive() { --smtp-password) export SMTP_PASSWORD=$1 && shift ;; + --smtp-disabled-templates) + export SMTP_DISABLED_TEMPLATES=$1 && shift + ;; --mas-smtpcfg-pod-template-yaml) export MAS_SMTPCFG_POD_TEMPLATE_YAML=$1 && shift ;; @@ -392,6 +398,19 @@ function gitops_mas_config_noninteractive() { [[ -z "$SMTP_DEFAULT_SENDER_EMAIL" ]] && gitops_mas_config_help "SMTP_DEFAULT_SENDER_EMAIL is not set" [[ -z "$SMTP_DEFAULT_SENDER_NAME" ]] && gitops_mas_config_help "SMTP_DEFAULT_SENDER_NAME is not set" [[ -z "$SMTP_DEFAULT_RECIPIENT_EMAIL" ]] && gitops_mas_config_help "SMTP_DEFAULT_RECIPIENT_EMAIL is not set" + + if [[ -n "${SMTP_DISABLED_TEMPLATES}" ]]; then + export SMTP_DISABLED_TEMPLATES + echo "${SMTP_DISABLED_TEMPLATES}" | yq --input-format=json 1>/dev/null || gitops_mas_config_help "SMTP_DISABLED_TEMPLATES is not valid JSON" + + # Check it's just a list of strings + echo "${SMTP_DISABLED_TEMPLATES}" | yq eval --input-format=json --exit-status=1 \ + 'type == "!!seq" and + (.[] | type == "!!str") as $item ireduce (true; . and $item)' \ + 1>/dev/null 2>&1 \ + || gitops_mas_config_help "SMTP_DISABLED_TEMPLATES must be a list of strings" + + fi fi fi # [ "${CONFIG_ACTION}" == "upsert" ] @@ -600,7 +619,8 @@ function gitops_mas_config() { echo_reset_dim "Smtp Default Recipient Email ................... ${COLOR_MAGENTA}${SMTP_DEFAULT_RECIPIENT_EMAIL}" echo_reset_dim "Smtp Should Email Passwords .................... ${COLOR_MAGENTA}${SMTP_DEFAULT_SHOULD_EMAIL_PASSWORDS}" echo_reset_dim "Smtp Server Username ........................... ${COLOR_MAGENTA}${SMTP_USERNAME}" - echo_reset_dim "Smtp Server Password ........................... ${COLOR_MAGENTA}${SMTP_PASSWORD:0:4}" + echo_reset_dim "Smtp Server Password ........................... ${COLOR_MAGENTA}${SMTP_PASSWORD:0:4}" + echo_reset_dim "Smtp Disabled Templates ........................ ${COLOR_MAGENTA}${SMTP_DISABLED_TEMPLATES}" echo_reset_dim "Pod Template YAML File ........................ ${COLOR_MAGENTA}${MAS_SMTPCFG_POD_TEMPLATE_YAML}" reset_colors fi diff --git a/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-smtp-config.yaml.j2 b/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-smtp-config.yaml.j2 index de9742a2af..ee1dc77334 100644 --- a/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-smtp-config.yaml.j2 +++ b/image/cli/mascli/templates/gitops/appset-configs/cluster/instance/configs/ibm-mas-smtp-config.yaml.j2 @@ -22,4 +22,8 @@ suite_smtp_default_should_email_passwords: {{ SMTP_DEFAULT_SHOULD_EMAIL_PASSWORD {% if MAS_SMTPCFG_POD_TEMPLATE is defined and MAS_SMTPCFG_POD_TEMPLATE !='' %} mas_smtpcfg_pod_templates: {{ MAS_SMTPCFG_POD_TEMPLATE | indent(2) }} +{% endif %} + +{% if SMTP_DISABLED_TEMPLATES is defined and SMTP_DISABLED_TEMPLATES !='' %} +suite_smtp_disabled_templates: {{ SMTP_DISABLED_TEMPLATES }} {% endif %} \ No newline at end of file diff --git a/tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2 b/tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2 index 349d670bb2..a097a3a5c8 100644 --- a/tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2 +++ b/tekton/src/pipelines/gitops/gitops-mas-instance.yml.j2 @@ -85,6 +85,8 @@ spec: type: string - name: smtp_use_sendgrid type: string + - name: smtp_disabled_templates + type: string - name: ldap_url type: string @@ -541,6 +543,8 @@ spec: value: $(params.smtp_default_recipient_email) - name: smtp_default_should_email_passwords value: $(params.smtp_default_should_email_passwords) + - name: smtp_disabled_templates + value: $(params.smtp_disabled_templates) - name: cluster_url value: $(params.cluster_url) - name: mas_smtpcfg_pod_template_yaml @@ -581,6 +585,8 @@ spec: value: $(params.github_host) - name: avp_aws_secret_region value: $(params.avp_aws_secret_region) + - name: smtp_disabled_templates + value: $(params.smtp_disabled_templates) - name: mas_smtpcfg_pod_template_yaml value: $(params.mas_smtpcfg_pod_template_yaml) diff --git a/tekton/src/tasks/gitops/gitops-suite-smtp-config-sendgrid.yml.j2 b/tekton/src/tasks/gitops/gitops-suite-smtp-config-sendgrid.yml.j2 index d91b0ff538..02aa641ee4 100644 --- a/tekton/src/tasks/gitops/gitops-suite-smtp-config-sendgrid.yml.j2 +++ b/tekton/src/tasks/gitops/gitops-suite-smtp-config-sendgrid.yml.j2 @@ -23,6 +23,9 @@ spec: type: string - name: avp_aws_secret_region type: string + - name: smtp_disabled_templates + type: string + default: "" - name: mas_smtpcfg_pod_template_yaml type: string default: "" @@ -56,6 +59,8 @@ spec: value: $(params.github_repo) - name: SM_AWS_REGION value: $(params.avp_aws_secret_region) + - name: SMTP_DISABLED_TEMPLATES + value: $(params.smtp_disabled_templates) - name: MAS_SMTPCFG_POD_TEMPLATE_YAML value: $(params.mas_smtpcfg_pod_template_yaml) @@ -208,6 +213,7 @@ spec: export SMTP_DEFAULT_SENDER_NAME="MASAdmin" export SMTP_DEFAULT_RECIPIENT_EMAIL="mas.ms.smtp@ibm.com" export SMTP_DEFAULT_SHOULD_EMAIL_PASSWORDS="true" + export SMTP_DISABLED_TEMPLATES # set in task env vars # Ensure any SMTP_USERNAME/SMTP_PASSWORD values set in pipeline context properties # are not used by the gitops-mas-config script to override the values in the AWS SM Secret @@ -237,6 +243,7 @@ spec: --smtp-default-sender-name "${SMTP_DEFAULT_SENDER_NAME}" \ --smtp-default-recipient-email "${SMTP_DEFAULT_RECIPIENT_EMAIL}" \ --smtp-default-should-email-passwords "${SMTP_DEFAULT_SHOULD_EMAIL_PASSWORDS}" \ + --smtp-disabled-templates "${SMTP_DISABLED_TEMPLATES}" \ --mas-smtpcfg-pod-template-yaml "${MAS_SMTPCFG_POD_TEMPLATE_YAML}" exit $? diff --git a/tekton/src/tasks/gitops/gitops-suite-smtp-config.yml.j2 b/tekton/src/tasks/gitops/gitops-suite-smtp-config.yml.j2 index a2f694b50e..5d32ae0908 100644 --- a/tekton/src/tasks/gitops/gitops-suite-smtp-config.yml.j2 +++ b/tekton/src/tasks/gitops/gitops-suite-smtp-config.yml.j2 @@ -47,6 +47,9 @@ spec: - name: smtp_default_should_email_passwords type: string default: "" + - name: smtp_disabled_templates + type: string + default: "" - name: cluster_url type: string default: "" @@ -92,6 +95,8 @@ spec: value: $(params.smtp_default_recipient_email) - name: SMTP_DEFAULT_SHOULD_EMAIL_PASSWORDS value: $(params.smtp_default_should_email_passwords) + - name: SMTP_DISABLED_TEMPLATES + value: $(params.smtp_disabled_templates) - name: MAS_SMTPCFG_POD_TEMPLATE_YAML value: $(params.mas_smtpcfg_pod_template_yaml) envFrom: