From 1e6889d8b47d1a667b728644b965f87e5d73987e Mon Sep 17 00:00:00 2001 From: Alexander Matyushentsev Date: Sat, 3 Apr 2021 21:59:55 -0700 Subject: [PATCH] feat: ArgoCD Notifications for Created, Deleted status (#231) Signed-off-by: Alexander Matyushentsev --- catalog/install.yaml | 24 ++++++++++++++++++++++++ catalog/templates/app-created.yaml | 5 +++++ catalog/templates/app-deleted.yaml | 5 +++++ catalog/triggers/on-created.yaml | 4 ++++ catalog/triggers/on-deleted.yaml | 4 ++++ docs/catalog.md | 22 ++++++++++++++++++++++ 6 files changed, 64 insertions(+) create mode 100644 catalog/templates/app-created.yaml create mode 100644 catalog/templates/app-deleted.yaml create mode 100644 catalog/triggers/on-created.yaml create mode 100644 catalog/triggers/on-deleted.yaml diff --git a/catalog/install.yaml b/catalog/install.yaml index 23ef0888..cce21d0a 100644 --- a/catalog/install.yaml +++ b/catalog/install.yaml @@ -1,5 +1,17 @@ apiVersion: v1 data: + template.app-created: | + email: + subject: Application {{.app.metadata.name}} has been created. + message: Application {{.app.metadata.name}} has been created. + teams: + title: Application {{.app.metadata.name}} has been created. + template.app-deleted: | + email: + subject: Application {{.app.metadata.name}} has been deleted. + message: Application {{.app.metadata.name}} has been deleted. + teams: + title: Application {{.app.metadata.name}} has been deleted. template.app-deployed: | email: subject: New version of an application {{.app.metadata.name}} is up and running. @@ -451,6 +463,18 @@ data: }] }] title: Application {{.app.metadata.name}} has been successfully synced + trigger.on-created: | + - description: Application is created. + oncePer: app.metadata.name + send: + - app-created + when: "true" + trigger.on-deleted: | + - description: Application is deleted. + oncePer: app.metadata.name + send: + - app-deleted + when: app.metadata.deletionTimestamp != nil trigger.on-deployed: | - description: Application is synced and healthy. Triggered once per commit. oncePer: app.status.operationState.syncResult.revision diff --git a/catalog/templates/app-created.yaml b/catalog/templates/app-created.yaml new file mode 100644 index 00000000..f620c714 --- /dev/null +++ b/catalog/templates/app-created.yaml @@ -0,0 +1,5 @@ +message: &message Application {{.app.metadata.name}} has been created. +email: + subject: *message +teams: + title: *message diff --git a/catalog/templates/app-deleted.yaml b/catalog/templates/app-deleted.yaml new file mode 100644 index 00000000..7164ab99 --- /dev/null +++ b/catalog/templates/app-deleted.yaml @@ -0,0 +1,5 @@ +message: &message Application {{.app.metadata.name}} has been deleted. +email: + subject: *message +teams: + title: *message diff --git a/catalog/triggers/on-created.yaml b/catalog/triggers/on-created.yaml new file mode 100644 index 00000000..aabc2e9f --- /dev/null +++ b/catalog/triggers/on-created.yaml @@ -0,0 +1,4 @@ +- when: true + description: Application is created. + send: [app-created] + oncePer: app.metadata.name diff --git a/catalog/triggers/on-deleted.yaml b/catalog/triggers/on-deleted.yaml new file mode 100644 index 00000000..682a98bd --- /dev/null +++ b/catalog/triggers/on-deleted.yaml @@ -0,0 +1,4 @@ +- when: app.metadata.deletionTimestamp != nil + description: Application is deleted. + send: [app-deleted] + oncePer: app.metadata.name diff --git a/docs/catalog.md b/docs/catalog.md index b4e04377..a0077cf2 100644 --- a/docs/catalog.md +++ b/docs/catalog.md @@ -2,6 +2,8 @@ ## Triggers | NAME | DESCRIPTION | TEMPLATE | |------------------------|---------------------------------------------------------------|-----------------------------------------------------| +| on-created | Application is created. | [app-created](#app-created) | +| on-deleted | Application is deleted. | [app-deleted](#app-deleted) | | on-deployed | Application is synced and healthy. Triggered once per commit. | [app-deployed](#app-deployed) | | on-health-degraded | Application has degraded | [app-health-degraded](#app-health-degraded) | | on-sync-failed | Application syncing has failed | [app-sync-failed](#app-sync-failed) | @@ -10,6 +12,26 @@ | on-sync-succeeded | Application syncing has succeeded | [app-sync-succeeded](#app-sync-succeeded) | ## Templates +### app-created +**definition**: +```yaml +email: + subject: Application {{.app.metadata.name}} has been created. +message: Application {{.app.metadata.name}} has been created. +teams: + title: Application {{.app.metadata.name}} has been created. + +``` +### app-deleted +**definition**: +```yaml +email: + subject: Application {{.app.metadata.name}} has been deleted. +message: Application {{.app.metadata.name}} has been deleted. +teams: + title: Application {{.app.metadata.name}} has been deleted. + +``` ### app-deployed **definition**: ```yaml