diff --git a/cronjob/Chart.yaml b/cronjob/Chart.yaml index ef5f629..190302e 100644 --- a/cronjob/Chart.yaml +++ b/cronjob/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 description: Helm chart with simple cronjob template name: cronjob -version: 0.9.0 +version: 0.10.0 appVersion: 1.0.0 tillerVersion: ">=2.14.3" diff --git a/cronjob/templates/_argo_cron_workflow.tpl b/cronjob/templates/_argo_cron_workflow.tpl index b7193d3..2d863bd 100644 --- a/cronjob/templates/_argo_cron_workflow.tpl +++ b/cronjob/templates/_argo_cron_workflow.tpl @@ -128,9 +128,11 @@ - # If .Values.exitNotifications.slackApp is set, slackApp will be notify if the job is done {{- if .Values.exitNotifications.slackApp }} + {{- if list nil true "true" | has .Values.exitNotifications.slackApp.sendOnSuccess }} - name: Notice-SlackApp-Succeeded template: notice-slack-app-succeeded {{- end }} + {{- end }} # If .Values.exitNotifications.healthcheckIo is set, Healthcheck IO will be notify if the job is done {{- if .Values.exitNotifications.healthcheckIo }} - name: Notice-HealthcheckIo-Succeeded @@ -142,9 +144,11 @@ - # If .Values.exitNotifications.slackApp is set, slackApp will be notify if the job is failed {{- if .Values.exitNotifications.slackApp }} + {{- if list nil true "true" | has .Values.exitNotifications.slackApp.sendOnFailure }} - name: Notice-SlackApp-Failed template: notice-slack-app-failed {{- end }} + {{- end }} # If .Values.exitNotifications.newRelic is set, New Relic will be notify if the job is failed {{- if .Values.exitNotifications.newRelic }} - name: Notice-NewRelic-Failed diff --git a/cronjob/templates/_exit_handler_slack_app.tpl b/cronjob/templates/_exit_handler_slack_app.tpl index 44345ae..6159574 100644 --- a/cronjob/templates/_exit_handler_slack_app.tpl +++ b/cronjob/templates/_exit_handler_slack_app.tpl @@ -1,5 +1,8 @@ {{- define "cronjob._exit_handler_slack_app" -}} {{- $slackApp := .Values.exitNotifications.slackApp | default dict -}} +{{- $sendOnSuccess := list nil true "true" | has $slackApp.sendOnSuccess -}} +{{- $sendOnFailure := list nil true "true" | has $slackApp.sendOnFailure -}} + {{- if eq $sendOnSuccess true }} - name: notice-slack-app-succeeded container: image: 332947256684.dkr.ecr.ap-southeast-1.amazonaws.com/curlimages/curl:8.4.0 @@ -86,6 +89,8 @@ ]}' {{ required "exitNotifications.slackApp.webhookUrl must be provided" $slackApp.webhookUrl }}" ] + {{- end -}} + {{- if eq $sendOnFailure true }} - name: notice-slack-app-failed container: image: 332947256684.dkr.ecr.ap-southeast-1.amazonaws.com/curlimages/curl:8.4.0 @@ -180,4 +185,5 @@ ]}' {{ required "exitNotifications.slackApp.webhookUrl must be provided" $slackApp.webhookUrl }}" ] + {{- end -}} {{- end -}} diff --git a/cronjob/values.yaml b/cronjob/values.yaml index 2aff308..7b4d27c 100644 --- a/cronjob/values.yaml +++ b/cronjob/values.yaml @@ -92,6 +92,8 @@ exitNotifications: slackApp: {} # example # slackApp: + # sendOnSuccess: true // optional, defaults to true + # sendOnFailure: true // optional, defaults to true # portalDomain: "https://argo.com" # webhookUrl: "https://webhook/service/test" # mention: