Skip to content

Latest commit

 

History

History
50 lines (44 loc) · 1.62 KB

templates.md

File metadata and controls

50 lines (44 loc) · 1.62 KB

Templates

Templates

The notification template is a stateless function that generates the notification content. The templates are leveraging html/template Golang package and allow you to customize notification messages. Templates are meant to be reusable and can be referenced by multiple triggers:

apiVersion: v1
kind: ConfigMap
metadata:
  name: <config-map-name>
data:
  template.app-sync-status: |
    message: |
      Application {{.app.metadata.name}} sync is {{.app.status.sync.status}}.
      Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.

Each template must define "basic" message template and optionally includes notification service specific fields:

apiVersion: v1
kind: ConfigMap
metadata:
  name: <config-map-name>
data:
  template.app-sync-status: |
    message: |
      Application {{.app.metadata.name}} sync is {{.app.status.sync.status}}.
      Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.
    slack:
      attachments: |
        [{
          "title": "{{.app.metadata.name}}",
          "title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
          "color": "#18be52",
          "fields": [{
            "title": "Sync Status",
            "value": "{{.app.status.sync.status}}",
            "short": true
          }, {
            "title": "Repository",
            "value": "{{.app.spec.source.repoURL}}",
            "short": true
          }]
        }]

Learn more about service-specific fields in the respective service documentation.