Skip to content

Commit ed1e563

Browse files
committed
fix: Ignore 422 response while creating commit statuses
Signed-off-by: Ragnar Paide <[email protected]>
1 parent 1f05776 commit ed1e563

29 files changed

+1838
-978
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
- name: Run golangci-lint
2828
uses: golangci/golangci-lint-action@v3
2929
with:
30-
version: v1.55.2
30+
version: v1.64.5
3131
args: --timeout 5m
3232
test:
3333
runs-on: ubuntu-latest

docs/services/github.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ template.app-deployed: |
8484
content: |
8585
Application {{.app.metadata.name}} is now running new version of deployments manifests.
8686
See more here: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true
87+
commentTag: "continuous-delivery/{{.app.metadata.name}}"
88+
checkRun:
89+
name: "continuous-delivery/{{.app.metadata.name}}"
90+
details_url: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
91+
status: completed
92+
conclusion: success
93+
started_at: "YYYY-MM-DDTHH:MM:SSZ"
94+
completed_at: "YYYY-MM-DDTHH:MM:SSZ"
95+
output:
96+
title: "Deployment of {{.app.metadata.name}} on ArgoCD"
97+
summary: "Application {{.app.metadata.name}} is now running new version of deployments manifests."
98+
text: |
99+
Application {{.app.metadata.name}} is now running new version of deployments manifests.
100+
See more here: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true
87101
```
88102
89103
**Notes**:
@@ -94,4 +108,9 @@ template.app-deployed: |
94108
Setting this option to `false` is required if you would like to deploy older refs in your default branch.
95109
For more information see the [GitHub Deployment API Docs](https://docs.github.com/en/rest/deployments/deployments?apiVersion=2022-11-28#create-a-deployment).
96110
- If `github.pullRequestComment.content` is set to 65536 characters or more, it will be truncated.
111+
- The `github.pullRequestComment.commentTag` parameter is used to identify the comment. If a comment with the specified tag is found, it will be updated (upserted). If no comment with the tag is found, a new comment will be created.
97112
- Reference is optional. When set, it will be used as the ref to deploy. If not set, the revision will be used as the ref to deploy.
113+
114+
## Commit Statuses
115+
116+
The [method for generating commit statuses](https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#create-a-commit-status) allows a maximum of 1000 attempts using the same commit SHA and context. Once this limit is reached, the API returns validation errors (HTTP 422). The notification engine ignores these errors and marks the notification attempts as completed.

docs/services/opsgenie.md

Lines changed: 50 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,34 @@
22

33
To be able to send notifications with argocd-notifications you have to create an [API Integration](https://docs.opsgenie.com/docs/integrations-overview) inside your [Opsgenie Team](https://docs.opsgenie.com/docs/teams).
44

5-
1. Login to Opsgenie at https://app.opsgenie.com or https://app.eu.opsgenie.com (if you have an account in the european union)
6-
2. Make sure you already have a team, if not follow this guide https://docs.opsgenie.com/docs/teams
7-
3. Click "Teams" in the Menu on the left
8-
4. Select the team that you want to notify
9-
5. In the teams configuration menu select "Integrations"
10-
6. Click "Add Integration" in the top right corner
11-
7. Select "API" integration
12-
8. Give your integration a name, copy the "API key" and safe it somewhere for later
13-
9. Click "Edit" in the integration settings
14-
10. Make sure the checkbox for "Create and Update Access" is selected, disable the other checkboxes to remove unnecessary permissions
15-
11. Click "Save" at the bottom
16-
12. Click "Turn on integration" in the top right corner
17-
13. Check your browser for the correct server apiURL. If it is "app.opsgenie.com" then use the US/international api url `api.opsgenie.com` in the next step, otherwise use `api.eu.opsgenie.com` (European API).
18-
14. You are finished with configuring Opsgenie. Now you need to configure argocd-notifications. Use the apiUrl, the team name and the apiKey to configure the Opsgenie integration in the `argocd-notifications-secret` secret.
19-
15. You can find the example `argocd-notifications-cm` configuration at the below.
5+
1. Login to Opsgenie at https://app.opsgenie.com or https://app.eu.opsgenie.com (if you have an account in the European Union).
6+
2. Make sure you already have a team; if not, follow this guide: https://docs.opsgenie.com/docs/teams.
7+
3. Click "Teams" in the Menu on the left.
8+
4. Select the team that you want to notify.
9+
5. In the team's configuration menu, select "Integrations".
10+
6. Click "Add Integration" in the top right corner.
11+
7. Select "API" integration.
12+
8. Give your integration a name, copy the "API key", and save it somewhere for later.
13+
9. Click "Edit" in the integration settings.
14+
10. Make sure the checkbox for "Create and Update Access" is selected; disable the other checkboxes to remove unnecessary permissions.
15+
11. Click "Save" at the bottom.
16+
12. Click "Turn on integration" in the top right corner.
17+
13. Check your browser for the correct server apiURL. If it is "app.opsgenie.com", then use the US/international API URL `api.opsgenie.com`; otherwise, use `api.eu.opsgenie.com` (European API).
18+
14. You are finished with configuring Opsgenie. Now you need to configure argocd-notifications. Use the apiUrl, the team name, and the apiKey to configure the Opsgenie integration in the `argocd-notifications-secret` secret.
19+
15. You can find the example `argocd-notifications-cm` configuration below.
2020

2121
| **Option** | **Required** | **Type** | **Description** | **Example** |
2222
| ------------- | ------------ | -------- | -------------------------------------------------------------------------------------------------------- | -------------------------------- |
23-
| `description` | True | `string` | Description field of the alert that is generally used to provide a detailed information about the alert. | `Hello from Argo CD!` |
24-
| `priority` | False | `string` | Priority level of the alert. Possible values are P1, P2, P3, P4 and P5. Default value is P3. | `P1` |
23+
| `description` | True | `string` | Description field of the alert that is generally used to provide detailed information about the alert. | `Hello from Argo CD!` |
24+
| `priority` | False | `string` | Priority level of the alert. Possible values are P1, P2, P3, P4, and P5. Default value is P3. | `P1` |
2525
| `alias` | False | `string` | Client-defined identifier of the alert, that is also the key element of Alert De-Duplication. | `Life is too short for no alias` |
26-
| `note` | False | `string` | Additional note that will be added while creating the alert. | `Error from Argo CD!` |
26+
| `note` | False | `string` | Additional note that will be added while creating the alert. | `Error from Argo CD!` |
27+
| `actions` | False | `[]string` | Custom actions that will be available for the alert. | `["Resolve", "Escalate"]` |
28+
| `tags` | False | `[]string` | Tags of the alert. | `["critical", "deployment"]` |
29+
| `visibleTo` | False | `[]alert.Responder` | Teams and users that the alert will become visible to without sending any notification. The `type` field is mandatory for each item, where possible values are `team` and `user`. In addition to the `type` field, either `id` or `name` should be provided for teams, and either `id` or `username` should be given for users. Please note that alerts will be visible to the teams specified within the `responders` field by default, so there is no need to re-specify them in the `visibleTo` field. | `[{Type: "team", Id: "team_id"}, {Type: "user", Id: "user_id"}]` |
30+
| `details` | False | `map[string]string` | Map of key-value pairs to use as custom properties of the alert. | `{"environment": "production", "service": "web"}` |
31+
| `entity` | False | `string` | Entity field of the alert that is generally used to specify which domain the alert is related to. | `web-server` |
32+
| `user` | False | `string` | Display name of the request owner. | `admin_user` |
2733

2834
```yaml
2935
apiVersion: v1
@@ -47,18 +53,38 @@ data:
4753
priority: P1
4854
alias: {{.app.metadata.name}}
4955
note: Error from Argo CD!
56+
actions:
57+
- Restart
58+
- AnExampleAction
59+
tags:
60+
- OverwriteQuietHours
61+
- Critical
62+
visibleTo:
63+
- Id: "{{.app.metadata.responderId}}"
64+
Type: "team"
65+
- Name: "rocket_team"
66+
Type: "team"
67+
- Id: "{{.app.metadata.responderUserId}}"
68+
Type: "user"
69+
- Username: "[email protected]"
70+
Type: "user"
71+
details:
72+
environment: production
73+
service: web
74+
entity: Argo CD Application
75+
user: John Doe
5076
trigger.on-a-problem: |
5177
- description: Application has a problem.
5278
send:
5379
- opsgenie
5480
when: app.status.health.status == 'Degraded' or app.status.operationState.phase in ['Error', 'Failed'] or app.status.sync.status == 'Unknown'
5581
```
5682
57-
16. Add annotation in application yaml file to enable notifications for specific Argo CD app.
83+
16. Add annotation in the application YAML file to enable notifications for a specific Argo CD app.
5884
```yaml
59-
apiVersion: argoproj.io/v1alpha1
60-
kind: Application
61-
metadata:
62-
annotations:
63-
notifications.argoproj.io/subscribe.on-a-problem.opsgenie: <your-team>
85+
apiVersion: argoproj.io/v1alpha1
86+
kind: Application
87+
metadata:
88+
annotations:
89+
notifications.argoproj.io/subscribe.on-a-problem.opsgenie: <your-team>
6490
```

docs/services/rocketchat.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The Rocket.Chat notification service configuration includes following settings:
66

7-
* `email` - the Rocker.Chat user's email
7+
* `email` - the Rocker.Chat user's SAMAccountName
88
* `password` - the Rocker.Chat user's password
99
* `alias` - optional alias that should be used to post message
1010
* `icon` - optional message icon
@@ -25,7 +25,7 @@ The Rocket.Chat notification service configuration includes following settings:
2525
4. Copy username and password that you was created for bot user
2626
5. Create a public or private channel, or a team, for this example `my_channel`
2727
6. Add your bot to this channel **otherwise it won't work**
28-
7. Store email and password in argocd_notifications-secret Secret
28+
7. Store email and password in argocd-notifications-secret Secret
2929

3030
```yaml
3131
apiVersion: v1

docs/services/slack.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ The Slack notification service configuration includes following settings:
2121

2222
1. Create Slack Application using https://api.slack.com/apps?new_app=1
2323
![1](https://user-images.githubusercontent.com/426437/73604308-4cb0c500-4543-11ea-9092-6ca6bae21cbb.png)
24-
1. Once application is created navigate to `Enter OAuth & Permissions`
24+
1. Once application is created navigate to `OAuth & Permissions`
2525
![2](https://user-images.githubusercontent.com/426437/73604309-4d495b80-4543-11ea-9908-4dea403d3399.png)
26-
1. Click `Permissions` under `Add features and functionality` section and add `chat:write` scope. To use the optional username and icon overrides in the Slack notification service also add the `chat:write.customize` scope.
26+
1. Go to `Scopes` > `Bot Token Scopes` > `Add an OAuth Scope`. Add `chat:write` scope. To use the optional username and icon overrides in the Slack notification service also add the `chat:write.customize` scope.
2727
![3](https://user-images.githubusercontent.com/426437/73604310-4d495b80-4543-11ea-8576-09cd91aea0e5.png)
28-
1. Scroll back to the top, click 'Install App to Workspace' button and confirm the installation.
28+
1. `OAuth & Permission` > `OAuth Tokens for Your Workspace` > `Install to Workspace`
2929
![4](https://user-images.githubusercontent.com/426437/73604311-4d495b80-4543-11ea-9155-9d216b20ec86.png)
3030
1. Once installation is completed copy the OAuth token.
3131
![5](https://user-images.githubusercontent.com/426437/73604312-4d495b80-4543-11ea-832b-a9d9d5e4bc29.png)
@@ -117,6 +117,35 @@ template.app-sync-status: |
117117
}]
118118
```
119119

120+
If you want to specify an icon and username for each message, you can specify values for `username` and `icon` in the `slack` field.
121+
For icon you can specify emoji and image URL, just like in the service definition.
122+
If you set `username` and `icon` in template, the values set in template will be used even if values are specified in the service definition.
123+
124+
```yaml
125+
template.app-sync-status: |
126+
message: |
127+
Application {{.app.metadata.name}} sync is {{.app.status.sync.status}}.
128+
Application details: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}.
129+
slack:
130+
username: "testbot"
131+
icon: https://example.com/image.png
132+
attachments: |
133+
[{
134+
"title": "{{.app.metadata.name}}",
135+
"title_link": "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}",
136+
"color": "#18be52",
137+
"fields": [{
138+
"title": "Sync Status",
139+
"value": "{{.app.status.sync.status}}",
140+
"short": true
141+
}, {
142+
"title": "Repository",
143+
"value": "{{.app.spec.source.repoURL}}",
144+
"short": true
145+
}]
146+
}]
147+
```
148+
120149
The messages can be aggregated to the slack threads by grouping key which can be specified in a `groupingKey` string field under `slack` field.
121150
`groupingKey` is used across each template and works independently on each slack channel.
122151
When multiple applications will be updated at the same time or frequently, the messages in slack channel can be easily read by aggregating with git commit hash, application name, etc.

docs/triggers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ data:
1515
```
1616
1717
* **trigger.\<name\>** - trigger name
18-
* **when** - a predicate expression that returns true or false. The expression evaluation is powered by [antonmedv/expr](https://github.com/antonmedv/expr).
19-
The condition language syntax is described at [Language-Definition.md](https://github.com/antonmedv/expr/blob/master/docs/Language-Definition.md).
18+
* **when** - a predicate expression that returns true or false. The expression evaluation is powered by [expr-lang/expr](https://github.com/expr-lang/expr).
19+
The condition language syntax is described at [Language-Definition.md](https://github.com/expr-lang/expr/blob/master/docs/Language-Definition.md).
2020
* **send** - the templates list that should be used to generate a notification.
2121
2222
### oncePer

0 commit comments

Comments
 (0)