Skip to content

Commit fffb30b

Browse files
Added web service for hooks
1 parent 21a2b68 commit fffb30b

File tree

1 file changed

+226
-0
lines changed

1 file changed

+226
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
apiVersion: v1
2+
data:
3+
service.webhook.tester: |
4+
url: https://webhook.site/#!/d2d2265f-adba-46ef-9ebd-47947cd4bba4
5+
template.app-deployed: |
6+
email:
7+
subject: New version of an application {{.app.metadata.name}} is up and running.
8+
message: |
9+
{{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} is now running new version of deployments manifests.
10+
slack:
11+
attachments: |
12+
[{
13+
"title": "{{ .app.metadata.name}}",
14+
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
15+
"color": "#18be52",
16+
"fields": [
17+
{
18+
"title": "Sync Status",
19+
"value": "{{.app.status.sync.status}}",
20+
"short": true
21+
},
22+
{
23+
"title": "Repository",
24+
"value": "{{.app.spec.source.repoURL}}",
25+
"short": true
26+
},
27+
{
28+
"title": "Revision",
29+
"value": "{{.app.status.sync.revision}}",
30+
"short": true
31+
}
32+
{{range $index, $c := .app.status.conditions}}
33+
{{if not $index}},{{end}}
34+
{{if $index}},{{end}}
35+
{
36+
"title": "{{$c.type}}",
37+
"value": "{{$c.message}}",
38+
"short": true
39+
}
40+
{{end}}
41+
]
42+
}]
43+
template.app-health-degraded: |
44+
email:
45+
subject: Application {{.app.metadata.name}} has degraded.
46+
message: |
47+
{{if eq .serviceType "slack"}}:exclamation:{{end}} Application {{.app.metadata.name}} has degraded.
48+
Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.
49+
slack:
50+
attachments: |-
51+
[{
52+
"title": "{{ .app.metadata.name}}",
53+
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
54+
"color": "#f4c030",
55+
"fields": [
56+
{
57+
"title": "Sync Status",
58+
"value": "{{.app.status.sync.status}}",
59+
"short": true
60+
},
61+
{
62+
"title": "Repository",
63+
"value": "{{.app.spec.source.repoURL}}",
64+
"short": true
65+
}
66+
{{range $index, $c := .app.status.conditions}}
67+
{{if not $index}},{{end}}
68+
{{if $index}},{{end}}
69+
{
70+
"title": "{{$c.type}}",
71+
"value": "{{$c.message}}",
72+
"short": true
73+
}
74+
{{end}}
75+
]
76+
}]
77+
template.app-sync-failed: |
78+
email:
79+
subject: Failed to sync application {{.app.metadata.name}}.
80+
message: |
81+
{{if eq .serviceType "slack"}}:exclamation:{{end}} The sync operation of application {{.app.metadata.name}} has failed at {{.app.status.operationState.finishedAt}} with the following error: {{.app.status.operationState.message}}
82+
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true .
83+
slack:
84+
attachments: |-
85+
[{
86+
"title": "{{ .app.metadata.name}}",
87+
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
88+
"color": "#E96D76",
89+
"fields": [
90+
{
91+
"title": "Sync Status",
92+
"value": "{{.app.status.sync.status}}",
93+
"short": true
94+
},
95+
{
96+
"title": "Repository",
97+
"value": "{{.app.spec.source.repoURL}}",
98+
"short": true
99+
}
100+
{{range $index, $c := .app.status.conditions}}
101+
{{if not $index}},{{end}}
102+
{{if $index}},{{end}}
103+
{
104+
"title": "{{$c.type}}",
105+
"value": "{{$c.message}}",
106+
"short": true
107+
}
108+
{{end}}
109+
]
110+
}]
111+
template.app-sync-running: |
112+
email:
113+
subject: Start syncing application {{.app.metadata.name}}.
114+
message: |
115+
The sync operation of application {{.app.metadata.name}} has started at {{.app.status.operationState.startedAt}}.
116+
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true .
117+
slack:
118+
attachments: |-
119+
[{
120+
"title": "{{ .app.metadata.name}}",
121+
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
122+
"color": "#0DADEA",
123+
"fields": [
124+
{
125+
"title": "Sync Status",
126+
"value": "{{.app.status.sync.status}}",
127+
"short": true
128+
},
129+
{
130+
"title": "Repository",
131+
"value": "{{.app.spec.source.repoURL}}",
132+
"short": true
133+
}
134+
{{range $index, $c := .app.status.conditions}}
135+
{{if not $index}},{{end}}
136+
{{if $index}},{{end}}
137+
{
138+
"title": "{{$c.type}}",
139+
"value": "{{$c.message}}",
140+
"short": true
141+
}
142+
{{end}}
143+
]
144+
}]
145+
template.app-sync-status-unknown: |
146+
email:
147+
subject: Application {{.app.metadata.name}} sync status is 'Unknown'
148+
message: |
149+
{{if eq .serviceType "slack"}}:exclamation:{{end}} Application {{.app.metadata.name}} sync is 'Unknown'.
150+
Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.
151+
{{if ne .serviceType "slack"}}
152+
{{range $c := .app.status.conditions}}
153+
* {{$c.message}}
154+
{{end}}
155+
{{end}}
156+
slack:
157+
attachments: |-
158+
[{
159+
"title": "{{ .app.metadata.name}}",
160+
"title_link":"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
161+
"color": "#E96D76",
162+
"fields": [
163+
{
164+
"title": "Sync Status",
165+
"value": "{{.app.status.sync.status}}",
166+
"short": true
167+
},
168+
{
169+
"title": "Repository",
170+
"value": "{{.app.spec.source.repoURL}}",
171+
"short": true
172+
}
173+
{{range $index, $c := .app.status.conditions}}
174+
{{if not $index}},{{end}}
175+
{{if $index}},{{end}}
176+
{
177+
"title": "{{$c.type}}",
178+
"value": "{{$c.message}}",
179+
"short": true
180+
}
181+
{{end}}
182+
]
183+
}]
184+
template.app-sync-succeeded: |
185+
email:
186+
subject: Application {{.app.metadata.name}} has been successfully synced.
187+
message: |
188+
{{if eq .serviceType "slack"}}:white_check_mark:{{end}} Application {{.app.metadata.name}} has been successfully synced at {{.app.status.operationState.finishedAt}}.
189+
Sync operation details are available at: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true .
190+
slack:
191+
attachments: "[{\n \"title\": \"{{ .app.metadata.name}}\",\n \"title_link\":\"{{.context.argocdUrl}}/applications/{{.app.metadata.name}}\",\n \"color\": \"#18be52\",\n \"fields\": [\n {\n \"title\": \"Sync Status\",\n \"value\": \"{{.app.status.sync.status}}\",\n \"short\": true\n },\n {\n \"title\": \"Repository\",\n \"value\": \"{{.app.spec.source.repoURL}}\",\n \"short\": true\n }\n {{range $index, $c := .app.status.conditions}}\n {{if not $index}},{{end}}\n {{if $index}},{{end}}\n {\n \"title\": \"{{$c.type}}\",\n \"value\": \"{{$c.message}}\",\n \"short\": true\n }\n {{end}}\n ]\n}] "
192+
trigger.on-deployed: |
193+
- description: Application is synced and healthy. Triggered once per commit.
194+
oncePer: app.status.sync.revision
195+
send:
196+
- app-deployed
197+
when: app.status.operationState.phase in ['Succeeded'] and app.status.health.status == 'Healthy'
198+
trigger.on-health-degraded: |
199+
- description: Application has degraded
200+
send:
201+
- app-health-degraded
202+
when: app.status.health.status == 'Degraded'
203+
trigger.on-sync-failed: |
204+
- description: Application syncing has failed
205+
send:
206+
- app-sync-failed
207+
when: app.status.operationState.phase in ['Error', 'Failed']
208+
trigger.on-sync-running: |
209+
- description: Application is being synced
210+
send:
211+
- app-sync-running
212+
when: app.status.operationState.phase in ['Running']
213+
trigger.on-sync-status-unknown: |
214+
- description: Application status is 'Unknown'
215+
send:
216+
- app-sync-status-unknown
217+
when: app.status.sync.status == 'Unknown'
218+
trigger.on-sync-succeeded: |
219+
- description: Application syncing has succeeded
220+
send:
221+
- app-sync-succeeded
222+
when: app.status.operationState.phase in ['Succeeded']
223+
kind: ConfigMap
224+
metadata:
225+
name: argocd-notifications-cm
226+
namespace: argocd

0 commit comments

Comments
 (0)