Skip to content

Commit

Permalink
chore: fix single quotes and double quotes errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nealyip committed Aug 4, 2024
1 parent 0df4602 commit 9c71cf7
Show file tree
Hide file tree
Showing 3 changed files with 191 additions and 162 deletions.
2 changes: 1 addition & 1 deletion cronjob/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
description: Helm chart with simple cronjob template
name: cronjob
version: 0.10.0
version: 0.11.0
appVersion: 1.0.0
tillerVersion: ">=2.14.3"
317 changes: 164 additions & 153 deletions cronjob/templates/_exit_handler_slack_app.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,183 +7,194 @@
container:
image: 332947256684.dkr.ecr.ap-southeast-1.amazonaws.com/curlimages/curl:8.4.0
command: [sh, -c]
args: [
"curl -X POST --tlsv1.2 --retry 3 --retry-all-errors --fail -H 'Content-type: application/json' --data '{\"attachments\": [
args:
- >
cat << ---EOF--- | curl -X POST --tlsv1.2 --retry 3 --retry-all-errors --fail -H 'Content-type: application/json' --data @- {{ required "exitNotifications.slackApp.webhookUrl must be provided" $slackApp.webhookUrl }}

{
\"fallback\": \"Workflow Succeeded - {{ "{{" }}workflow.name{{ "}}" }}\",
\"color\": \"#18be52\",
\"blocks\": [
{
\"type\": \"header\",
\"text\": {
\"type\": \"plain_text\",
\"text\": \"Workflow Succeeded - {{ "{{" }}workflow.name{{ "}}" }}\",
\"emoji\": true
}
},
{
\"type\": \"divider\"
},
{
\"type\": \"section\",
\"fields\": [
{
\"type\": \"mrkdwn\",
\"text\": \"*Cluster*\\n{{ .Values.clusterName | default "unknown"}}\"
},
{
\"type\": \"mrkdwn\",
\"text\": \"*Namespace*\\n{{ "{{" }}workflow.namespace{{ "}}" }}\"
},
{
\"type\": \"mrkdwn\",
\"text\": \"*Scheduled Time*\\n{{ "{{" }}workflow.scheduledTime{{ "}}" }}\"
},
{
\"type\": \"mrkdwn\",
\"text\": \"*Duration*\\n{{ "{{" }}workflow.duration{{ "}}" }} sec\"
"attachments": [
{
"fallback": "Workflow Succeeded - {{ "{{" }}workflow.name{{ "}}" }}",
"color": "#18be52",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Workflow Succeeded - {{ "{{" }}workflow.name{{ "}}" }}",
"emoji": true
}
]
}
{{- if $slackApp.mention }}
{{- if $slackApp.mention.onSuccess }}
,{
\"type\": \"section\",
\"text\": {
\"type\": \"mrkdwn\",
\"text\": \"{{ range $slackApp.mention.onSuccess -}}{{ if (hasPrefix "S" .) }}<!subteam^{{.}}>{{ else }}<@{{.}}> {{ end }}{{ end }}\"
}
}
{{- end }}
{{- end }}
,
{
\"type\": \"actions\",
\"elements\": [
{
\"type\": \"button\",
\"text\": {
\"type\": \"plain_text\",
\"text\": \"Argo Dashboard\"
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Cluster*\n{{ .Values.clusterName | default "unknown"}}"
},
\"url\": \"{{required "exitNotifications.slackApp.portalDomain must be provided" $slackApp.portalDomain}}/workflows/{{ "{{" }}workflow.namespace{{ "}}" }}/{{ "{{" }}workflow.name{{ "}}" }}?tab=workflow\"
}
{{- if $slackApp.customUrls }}
{{- range $index, $value := $slackApp.customUrls }}
{{- with $value }}
,{
\"type\": \"button\",
\"text\": {
\"type\": \"plain_text\",
\"text\": \"{{.title}}\"
{
"type": "mrkdwn",
"text": "*Namespace*\n{{ "{{" }}workflow.namespace{{ "}}" }}"
},
\"url\": \"{{.url}}\"
{
"type": "mrkdwn",
"text": "*Scheduled Time*\n{{ "{{" }}workflow.scheduledTime{{ "}}" }}"
},
{
"type": "mrkdwn",
"text": "*Duration*\n{{ "{{" }}workflow.duration{{ "}}" }} sec"
}
]
}
{{- if $slackApp.mention }}
{{- if $slackApp.mention.onSuccess }}
,{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "{{ range $slackApp.mention.onSuccess -}}{{ if (hasPrefix "S" .) }}<!subteam^{{.}}>{{ else }}<@{{.}}> {{ end }}{{ end }}"
}
}
{{- end }}
{{- end }}
{{- end }}
]
}
,
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Argo Dashboard"
},
"url": "{{required "exitNotifications.slackApp.portalDomain must be provided" $slackApp.portalDomain}}/workflows/{{ "{{" }}workflow.namespace{{ "}}" }}/{{ "{{" }}workflow.name{{ "}}" }}?tab=workflow"
}
{{- if $slackApp.customUrls }}
{{- range $index, $value := $slackApp.customUrls }}
{{- with $value }}
,{
"type": "button",
"text": {
"type": "plain_text",
"text": {{.title | quote}}
},
"url": {{.url | quote}}
}
{{- end }}
{{- end }}
{{- end }}
]
}
]
}
]
}
]}'
{{ required "exitNotifications.slackApp.webhookUrl must be provided" $slackApp.webhookUrl }}"
]

---EOF---
{{- 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
command: [sh, -c]
args: [
"curl -X POST --tlsv1.2 --retry 3 --retry-all-errors --fail -H 'Content-type: application/json' --data '{\"attachments\": [
args:
- >
cat << ---EOF--- | curl -X POST --tlsv1.2 --retry 3 --retry-all-errors --fail -H 'Content-type: application/json' --data @- {{ required "exitNotifications.slackApp.webhookUrl must be provided" $slackApp.webhookUrl }}

{
\"fallback\": \"Workflow Failed - {{ "{{" }}workflow.name{{ "}}" }}\",
\"color\": \"#E01E5A\",
\"blocks\": [
{
\"type\": \"header\",
\"text\": {
\"type\": \"plain_text\",
\"text\": \"Workflow Failed - {{ "{{" }}workflow.name{{ "}}" }}\",
\"emoji\": true
}
},
{
\"type\": \"divider\"
},
{
\"type\": \"section\",
\"fields\": [
{
\"type\": \"mrkdwn\",
\"text\": \"*Cluster*\\n{{ .Values.clusterName | default "unknown"}}\"
},
{
\"type\": \"mrkdwn\",
\"text\": \"*Namespace*\\n{{ "{{" }}workflow.namespace{{ "}}" }}\"
},
{
\"type\": \"mrkdwn\",
\"text\": \"*Scheduled Time*\\n{{ "{{" }}workflow.scheduledTime{{ "}}" }}\"
},
{
\"type\": \"mrkdwn\",
\"text\": \"*Duration*\\n{{ "{{" }}workflow.duration{{ "}}" }} sec\"
"attachments": [
{
"fallback": "Workflow Failed - {{ "{{" }}workflow.name{{ "}}" }}",
"color": "#E01E5A",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Workflow Failed - {{ "{{" }}workflow.name{{ "}}" }}",
"emoji": true
}
]
}
{{- if $slackApp.mention }}
{{- if $slackApp.mention.onFailure }}
,{
\"type\": \"section\",
\"text\": {
\"type\": \"mrkdwn\",
\"text\": \"{{ range $slackApp.mention.onFailure -}}{{ if (hasPrefix "S" .) }}<!subteam^{{.}}>{{ else }}<@{{.}}> {{ end }}{{ end }}\"
}
}
{{- end }}
{{- end }}
{{- if $slackApp.runbook }}
,{
\"type\": \"section\",
\"text\": {
\"type\": \"mrkdwn\",
\"text\": \"*Runbook*{{- range $line := $slackApp.runbook }}\\n{{$line}}{{- end}}\"
}
}
{{- end }}
,{
\"type\": \"actions\",
\"elements\": [
{
\"type\": \"button\",
\"text\": {
\"type\": \"plain_text\",
\"text\": \"Argo Dashboard\"
},
{
"type": "divider"
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Cluster*\n{{ .Values.clusterName | default "unknown"}}"
},
\"url\": \"{{required "exitNotifications.slackApp.portalDomain must be provided" $slackApp.portalDomain}}/workflows/{{ "{{" }}workflow.namespace{{ "}}" }}/{{ "{{" }}workflow.name{{ "}}" }}?tab=workflow\"
}
{{- if $slackApp.customUrls }}
{{- range $index, $value := $slackApp.customUrls }}
{{- with $value }}
,{
\"type\": \"button\",
\"text\": {
\"type\": \"plain_text\",
\"text\": \"{{.title}}\"
{
"type": "mrkdwn",
"text": "*Namespace*\n{{ "{{" }}workflow.namespace{{ "}}" }}"
},
\"url\": \"{{.url}}\"
{
"type": "mrkdwn",
"text": "*Scheduled Time*\n{{ "{{" }}workflow.scheduledTime{{ "}}" }}"
},
{
"type": "mrkdwn",
"text": "*Duration*\n{{ "{{" }}workflow.duration{{ "}}" }} sec"
}
]
}
{{- if $slackApp.mention }}
{{- if $slackApp.mention.onFailure }}
,{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "{{ range $slackApp.mention.onFailure -}}{{ if (hasPrefix "S" .) }}<!subteam^{{.}}>{{ else }}<@{{.}}> {{ end }}{{ end }}"
}
}
{{- end }}
{{- end }}
{{- if $slackApp.runbook }}
,{
"type": "section",
"text": {
"type": "mrkdwn",
{{- $joined := join "\n" $slackApp.runbook }}
"text": {{ printf "*Runbook*\n%s" $joined | quote }}
}
}
{{- end }}
]
}
,{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "Argo Dashboard"
},
"url": "{{required "exitNotifications.slackApp.portalDomain must be provided" $slackApp.portalDomain}}/workflows/{{ "{{" }}workflow.namespace{{ "}}" }}/{{ "{{" }}workflow.name{{ "}}" }}?tab=workflow"
}
{{- if $slackApp.customUrls }}
{{- range $index, $value := $slackApp.customUrls }}
{{- with $value }}
,{
"type": "button",
"text": {
"type": "plain_text",
"text": {{.title | quote}}
},
"url": {{.url | quote}}
}
{{- end }}
{{- end }}
{{- end }}
]
}
]
}
]
}
]}'
{{ required "exitNotifications.slackApp.webhookUrl must be provided" $slackApp.webhookUrl }}"
]

---EOF---
{{- end -}}
{{- end -}}
Loading

0 comments on commit 9c71cf7

Please sign in to comment.