diff --git a/notifier/.s2i/bin/assemble b/notifier/.s2i/bin/assemble new file mode 100755 index 000000000..4e989c84b --- /dev/null +++ b/notifier/.s2i/bin/assemble @@ -0,0 +1,6 @@ +#!/bin/bash + +npm install -g npm@8.19.3 +npm install -g mjml@4.13.0 + +exec /usr/libexec/s2i/assemble \ No newline at end of file diff --git a/notifier/Containerfile b/notifier/Containerfile index bf35962b0..2a8880de1 100644 --- a/notifier/Containerfile +++ b/notifier/Containerfile @@ -9,10 +9,11 @@ RUN dnf install -y ruby ruby-libs && \ rm -rf /tmp/src/.git* && \ chown -R 1001 /tmp/src && \ chgrp -R 0 /tmp/src && \ - chmod -R g+w /tmp/src + chmod -R g+w /tmp/src \ + cp -rp /tmp/src/.s2i/bin /tmp/scripts USER 1001 -RUN /usr/libexec/s2i/assemble +RUN /tmp/scripts/assemble CMD ["/usr/libexec/s2i/run"] diff --git a/notifier/devfile.yaml b/notifier/devfile.yaml index 248f79961..9b73ddb65 100644 --- a/notifier/devfile.yaml +++ b/notifier/devfile.yaml @@ -1,6 +1,7 @@ commands: - exec: - commandLine: /usr/libexec/s2i/assemble + commandLine: >- + rm -rf /tmp/src && cp /tmp/projects -r /tmp/src && /tmp/src/.s2i/bin/assemble component: s2i-builder group: isDefault: true diff --git a/notifier/operator/operator.py b/notifier/operator/operator.py index fb40d89bb..ab4ff6dc4 100755 --- a/notifier/operator/operator.py +++ b/notifier/operator/operator.py @@ -766,6 +766,7 @@ async def send_notification_email( ) ) template_vars['have_attachments'] = len(attachments) > 0 + template_vars['service_status'] = ' '.join(elem.capitalize() for elem in template.replace('-', ' ').split()) email_subject = j2env.from_string(subject).render(**template_vars) @@ -775,11 +776,11 @@ async def send_notification_email( message_template = catalog_item.get_message_template(kebabToCamelCase(template)) if message_template: try: - email_body = j2env.from_string(message_template).render(**template_vars) + mjml_template = j2env.from_string(message_template).render(**template_vars) except Exception as exception: logger.warning(f"Failed to render template: {exception}") - email_body = j2env.get_template(template + '.html.j2').render(**template_vars) - email_body += ( + mjml_template = j2env.get_template(template + '.html.j2').render(**template_vars) + mjml_template += ( "
Attention: " "A custom message template was configured for your service, " "but unfortunately, rendering failed with the following error:
" @@ -787,7 +788,14 @@ async def send_notification_email( "The content shown above is the default message template.
" ) else: - email_body = j2env.get_template(template + '.html.j2').render(**template_vars) + mjml_template = j2env.get_template(template + '.mjml.j2').render(**template_vars) + + # Call for the MJML CLI to generate final HTML + email_body = subprocess.run( + ['mjml', '-i'], + stdout=subprocess.PIPE, + input=mjml_template, + encoding='ascii').stdout msg = MIMEMultipart('alternative') msg['Subject'] = email_subject diff --git a/notifier/operator/templates/base.mjml.j2 b/notifier/operator/templates/base.mjml.j2 new file mode 100644 index 000000000..f4c84ddec --- /dev/null +++ b/notifier/operator/templates/base.mjml.j2 @@ -0,0 +1,54 @@ +Your {{ catalog_namespace.display_name }} service, {{ service_display_name }}, has failed to provision. -{% if have_attachments %} -Please see attached Ansible log. -{% endif %} -
- -{% if service_url %} -You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Your {{ catalog_namespace.display_name }} service, {{ service_display_name }}, has failed to provision. + {% if have_attachments %} + Please see attached Ansible log. + {% endif %} +
+ + {% if service_url %} +You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.
Thank you for ordering {{ catalog_item.display_name }}.
- -Provisioning has started on your {{ catalog_namespace.display_name }} service, {{ service_display_name }}.
- -You will receive more information via email when the provisioning completes in about {{ provision_time_estimate }}.
- -Please note that the environment is set to auto-stop at {{ stop_timestamp }} and auto-destroy at {{ retirement_timestamp }}.
- -You can change the auto-stop and auto-destroy time in UI.
- -{% if service_url %} -You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Thank you for ordering {{ catalog_item.display_name }}.
+ +Provisioning has started on your {{ catalog_namespace.display_name }} service, {{ service_display_name }}.
+ +You will receive more information via email when the provisioning completes in about {{ provision_time_estimate }}.
+ +Please note that the environment is set to auto-stop at {{ stop_timestamp }} and auto-destroy at {{ retirement_timestamp }}.
+ +You can change the auto-stop and auto-destroy time in UI.
+ + {% if service_url %} +You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.
Reminder:
-Your environment will expire and be deleted in {{ retirement_timedelta_humanized }} at {{ retirement_timestamp }}.
You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Reminder:
+ Your environment will expire and be deleted in {{ retirement_timedelta_humanized }} at {{ retirement_timestamp }}.
You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} has been deleted.
- -To conserve resources data on these systems is not archived and cannot be retrieved. -We apologize for any inconvenience this may cause. -Thank you for using {{ catalog_namespace.display_name }}.
- -{% if survey_link %} -We would love your feedback on your demo/lab, please fill out our short Survey (click here) to help us improve your experience.
-{% endif %} diff --git a/notifier/operator/templates/service-deleted.mjml.j2 b/notifier/operator/templates/service-deleted.mjml.j2 new file mode 100644 index 000000000..fe4ed5e4c --- /dev/null +++ b/notifier/operator/templates/service-deleted.mjml.j2 @@ -0,0 +1,21 @@ +{% extends "base.mjml.j2" %} +{% block content %} + +Your {{ catalog_namespace.display_name }} service {{ service_display_name }} has been deleted.
+ +To conserve resources data on these systems is not archived and cannot be retrieved. + We apologize for any inconvenience this may cause.
+ +Thank you for using {{ catalog_namespace.display_name }}.
+ + {% if survey_link %} +We would love your feedback on your demo/lab, please fill out our short Survey (click here) to help us improve your experience.
+ {% endif %} + +Thank you for ordering {{ catalog_item.display_name }}.
- -Your {{ catalog_namespace.display_name }} service {{ service_display_name }} is ready.
- -Please refer to the instructions for next steps and how to access your environment.
- -Troubleshooting and Access issues:
- -Always refer to the instructions to understand how to properly access and navigate your environment.
- -NOTICE:
-Your environment will be stopped in {{ stop_timedelta_humanized }} at {{ stop_timestamp }}.
-Your environment will expire and be deleted in {{ retirement_timedelta_humanized }} at {{ retirement_timestamp }}.
In order to conserve resources, we cannot archive or restore any data in this environment. -All data will be lost upon expiration.
- -{% if provision_messages is defined %} -Here is some important information about your environment:
-{{ provision_messages_html }} -{% endif %} - -{% if service_url %} -You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Thank you for ordering {{ catalog_item.display_name }}.
+ +Your {{ catalog_namespace.display_name }} service {{ service_display_name }} is ready.
+ +Please refer to the instructions for next steps and how to access your environment.
+ +Troubleshooting and Access issues:
+ +Always refer to the instructions to understand how to properly access and navigate your environment.
+ +NOTICE:
+ Your environment will be stopped in {{ stop_timedelta_humanized }} at {{ stop_timestamp }}.
+ Your environment will expire and be deleted in {{ retirement_timedelta_humanized }} at {{ retirement_timestamp }}.
In order to conserve resources, we cannot archive or restore any data in this environment. + All data will be lost upon expiration.
+ + {% if provision_messages is defined %} +Here is some important information about your environment:
+ {{ provision_messages_html }} + {% endif %} + + {% if service_url %} +You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} has started.
- -NOTICE:
-Your environment will be stopped in {{ stop_timedelta_humanized }} at {{ stop_timestamp }}.
-Your environment will expire and be deleted in {{ retirement_timedelta_humanized }} at {{ retirement_timestamp }}.
You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} has started.
+ +
+ NOTICE:
+
You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} failed to start. -{% if have_attachments %} -Please see attached Ansible log. -{% endif %} -
- -{% if service_url %} -You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} failed to start. + {% if have_attachments %} + Please see attached Ansible log. + {% endif %} +
+ + {% if service_url %} +You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} has stopped.
- -{% if service_url %} -You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} has stopped.
+ + {% if service_url %} +You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} failed to stop. -{% if have_attachments %} -Please see attached Ansible log. -{% endif %} -
- -{% if service_url %} -You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Your {{ catalog_namespace.display_name }} service {{ service_display_name }} failed to stop. + {% if have_attachments %} + Please see attached Ansible log. + {% endif %} +
+ + {% if service_url %} +You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.
Reminder:
-Your environment will be stopped in {{ stop_timedelta_humanized }} at {{ stop_timestamp }}.
You may manage your {{ catalog_namespace.display_name }} service at:
-{{ service_url }}.
Reminder:
+ Your environment will be stopped in {{ stop_timedelta_humanized }} at {{ stop_timestamp }}.
You may manage your {{ catalog_namespace.display_name }} service at:
+ {{ service_url }}.