Acccessing notification annotation value #10396
Answered
by
brunocascio
brunocascio
asked this question in
Q&A
-
Hi everyone! I'm trying to access the annotation value in order to configure my webhook notification: My application is defined as: apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: app
namespace: argocd
finalizers:
- resources-finalizer.argocd.argoproj.io
spec:
generators:
- list:
elements:
- environment: dev
cluster: dev
template:
metadata:
name: 'app-{{environment}}'
annotations:
notifications.argoproj.io/subscribe.on-sync-succeeded.newrelic: "123456789" # <-- here my annotation
spec:
project: "app"
source:
repoURL: https://example.com/repo.git
targetRevision: HEAD
path: '{{environment}}/'
destination:
name: '{{cluster}}'
namespace: 'app-{{environment}}'
syncPolicy:
automated:
selfHeal: true
prune: true
syncOptions:
- CreateNamespace=true This is my config map: apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.webhook.newrelic: |
url: https://api.newrelic.com/v2/applications
headers:
- name: X-Api-Key
value: <redacted>
- name: Content-Type
value: application/json
template.newrelic-record-deployment: |
webhook:
newrelic:
method: POST
path: "/{{ how-to-access-annotation-value?? }}/deployments.json" # <--- How to access the annotation value?
body: |
{
"deployment": {
"revision": "{{ .app.status.sync.revision }}",
"changelog": "{{ .app.metadata.name }}",
"description": "Synced {{ .app.metadata.name }}",
"user": "argocd",
"timestamp": "{{ .app.status.operationState.startedAt }}"
}
}
trigger.on-sync-succeeded: |
- when: app.status.operationState.phase in ['Succeeded']
send: [newrelic-record-deployment] |
Beta Was this translation helpful? Give feedback.
Answered by
brunocascio
Aug 18, 2022
Replies: 1 comment
-
Found it. For future references, the value of the annotation is available under So, the result is: path: "/{{ .recipient }}/deployments.json" |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
brunocascio
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Found it. For future references, the value of the annotation is available under
.recipient
.So, the result is: