Skip to content

Commit

Permalink
fix: bump notification-engine to fix double send on self server notif…
Browse files Browse the repository at this point in the history
…ications (#3095)

* bump notification-engine to fix double send on self server notifications

Signed-off-by: zachaller <zachaller@users.noreply.github.com>

* codegen

Signed-off-by: zachaller <zachaller@users.noreply.github.com>

---------

Signed-off-by: zachaller <zachaller@users.noreply.github.com>
  • Loading branch information
zachaller committed Oct 25, 2023
1 parent 725dd4d commit 0d9983e
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 111 deletions.
106 changes: 106 additions & 0 deletions docs/generated/notification-services/awssqs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# AWS SQS

## Parameters

This notification service is capable of sending simple messages to AWS SQS queue.

* `queue` - name of the queue you are intending to send messages to. Can be overwriten with target destination annotation.
* `region` - region of the sqs queue can be provided via env variable AWS_DEFAULT_REGION
* `key` - optional, aws access key must be either referenced from a secret via variable or via env variable AWS_ACCESS_KEY_ID
* `secret` - optional, aws access secret must be either referenced from a secret via variableor via env variable AWS_SECRET_ACCESS_KEY
* `account` optional, external accountId of the queue
* `endpointUrl` optional, useful for development with localstack

## Example

### Using Secret for credential retrieval:

Resource Annotation:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
notifications.argoproj.io/subscribe.on-deployment-ready.awssqs: "overwrite-myqueue"
```
* ConfigMap
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: <config-map-name>
data:
service.awssqs: |
region: "us-east-2"
queue: "myqueue"
account: "1234567"
key: "$awsaccess_key"
secret: "$awsaccess_secret"
template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
trigger.on-deployment-ready: |
- when: any(obj.status.conditions, {.type == 'Available' && .status == 'True'})
send: [deployment-ready]
- oncePer: obj.metadata.annotations["generation"]
```
Secret
```yaml
apiVersion: v1
kind: Secret
metadata:
name: <secret-name>
stringData:
awsaccess_key: test
awsaccess_secret: test
```
### Minimal configuration using AWS Env variables
Ensure following list of enviromental variable is injected via OIDC, or other method. And assuming SQS is local to the account.
You may skip usage of secret for sensitive data and omit other parameters. (Setting parameters via ConfigMap takes precedent.)
Variables:
```bash
export AWS_ACCESS_KEY_ID="test"
export AWS_SECRET_ACCESS_KEY="test"
export AWS_DEFAULT_REGION="us-east-1"
```

Resource Annotation:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
notifications.argoproj.io/subscribe.on-deployment-ready.awssqs: ""
```
* ConfigMap
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: <config-map-name>
data:
service.awssqs: |
queue: "myqueue"
template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
trigger.on-deployment-ready: |
- when: any(obj.status.conditions, {.type == 'Available' && .status == 'True'})
send: [deployment-ready]
- oncePer: obj.metadata.annotations["generation"]
```
11 changes: 10 additions & 1 deletion docs/generated/notification-services/github.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The GitHub notification service changes commit status using [GitHub Apps](https:
## Configuration

1. Create a GitHub Apps using https://github.com/settings/apps/new
2. Change repository permissions to enable write commit statuses and/or deployments
2. Change repository permissions to enable write commit statuses and/or deployments and/or pull requests comments
![2](https://user-images.githubusercontent.com/18019529/108397381-3ca57980-725b-11eb-8d17-5b8992dc009e.png)
3. Generate a private key, and download it automatically
![3](https://user-images.githubusercontent.com/18019529/108397926-d4a36300-725b-11eb-83fe-74795c8c3e03.png)
Expand Down Expand Up @@ -75,8 +75,17 @@ template.app-deployed: |
environmentURL: "https://{{.app.metadata.name}}.example.com"
logURL: "{{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true"
requiredContexts: []
autoMerge: true
pullRequestComment:
content: |
Application {{.app.metadata.name}} is now running new version of deployments manifests.
See more here: {{.context.argocdUrl}}/applications/{{.app.metadata.name}}?operation=true
```
**Notes**:
- If the message is set to 140 characters or more, it will be truncated.
- If `github.repoURLPath` and `github.revisionPath` are same as above, they can be omitted.
- Automerge is optional and `true` by default for github deployments to ensure the requested ref is up to date with the default branch.
Setting this option to `false` is required if you would like to deploy older refs in your default branch.
For more information see the [Github Deployment API Docs](https://docs.github.com/en/rest/deployments/deployments?apiVersion=2022-11-28#create-a-deployment).
- If `github.pullRequestComment.content` is set to 65536 characters or more, it will be truncated.
19 changes: 11 additions & 8 deletions docs/generated/notification-services/googlechat.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,27 @@ A card message can be defined as follows:
```yaml
template.app-sync-succeeded: |
googlechat:
cards: |
cardsV2: |
- header:
title: ArgoCD Bot Notification
sections:
- widgets:
- textParagraph:
- decoratedText:
text: The app {{ .app.metadata.name }} has successfully synced!
- widgets:
- keyValue:
- decoratedText:
topLabel: Repository
content: {{ call .repo.RepoURLToHTTPS .app.spec.source.repoURL }}
- keyValue:
text: {{ call .repo.RepoURLToHTTPS .app.spec.source.repoURL }}
- decoratedText:
topLabel: Revision
content: {{ .app.spec.source.targetRevision }}
- keyValue:
text: {{ .app.spec.source.targetRevision }}
- decoratedText:
topLabel: Author
content: {{ (call .repo.GetCommitMetadata .app.status.sync.revision).Author }}
text: {{ (call .repo.GetCommitMetadata .app.status.sync.revision).Author }}
```
All [Card fields](https://developers.google.com/chat/api/reference/rest/v1/cards#Card_1) are supported and can be used
in notifications. It is also possible to use the previous (now deprecated) `cards` key to use the legacy card fields,
but this is not recommended as Google has deprecated this field and recommends using the newer `cardsV2`.

The card message can be written in JSON too.

Expand Down
6 changes: 6 additions & 0 deletions docs/generated/notification-services/grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ To be able to create Grafana annotation with argocd-notifications you have to cr

![sample](https://user-images.githubusercontent.com/18019529/112024976-0f106080-8b78-11eb-9658-7663305899be.png)

Available parameters :

* `apiURL` - the server url, e.g. https://grafana.example.com
* `apiKey` - the API key for the serviceaccount
* `insecureSkipVerify` - optional bool, true or false

1. Login to your Grafana instance as `admin`
2. On the left menu, go to Configuration / API Keys
3. Click "Add API Key"
Expand Down
1 change: 1 addition & 0 deletions docs/generated/notification-services/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ metadata:

## Service Types

* [AwsSqs](./awssqs.md)
* [Email](./email.md)
* [GitHub](./github.md)
* [Slack](./slack.md)
Expand Down
82 changes: 41 additions & 41 deletions docs/generated/notification-services/slack.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,56 +29,56 @@ The Slack notification service configuration includes following settings:
1. Invite your slack bot to this channel **otherwise slack bot won't be able to deliver notifications to this channel**
1. Store Oauth access token in `argocd-notifications-secret` secret

```yaml
apiVersion: v1
kind: Secret
metadata:
name: <secret-name>
stringData:
slack-token: <Oauth-access-token>
```
```yaml
apiVersion: v1
kind: Secret
metadata:
name: <secret-name>
stringData:
slack-token: <Oauth-access-token>
```
1. Define service type slack in data section of `argocd-notifications-cm` configmap:

```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: <config-map-name>
data:
service.slack: |
token: $slack-token
```
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: <config-map-name>
data:
service.slack: |
token: $slack-token
```

1. Add annotation in application yaml file to enable notifications for specific argocd app. The following example uses the [on-sync-succeeded trigger](../catalog.md#triggers):

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my_channel
```
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
notifications.argoproj.io/subscribe.on-sync-succeeded.slack: my_channel
```

1. Annotation with more than one [trigger](../catalog.md#triggers), with multiple destinations and recipients

```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
notifications.argoproj.io/subscriptions: |
- trigger: [on-scaling-replica-set, on-rollout-updated, on-rollout-step-completed]
destinations:
- service: slack
recipients: [my-channel-1, my-channel-2]
- service: email
recipients: [recipient-1, recipient-2, recipient-3 ]
- trigger: [on-rollout-aborted, on-analysis-run-failed, on-analysis-run-error]
destinations:
- service: slack
recipients: [my-channel-21, my-channel-22]
```
```yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
annotations:
notifications.argoproj.io/subscriptions: |
- trigger: [on-scaling-replica-set, on-rollout-updated, on-rollout-step-completed]
destinations:
- service: slack
recipients: [my-channel-1, my-channel-2]
- service: email
recipients: [recipient-1, recipient-2, recipient-3 ]
- trigger: [on-rollout-aborted, on-analysis-run-failed, on-analysis-run-error]
destinations:
- service: slack
recipients: [my-channel-21, my-channel-22]
```

## Templates

Expand Down
Loading

0 comments on commit 0d9983e

Please sign in to comment.