argoproj / argoproj/notifications-engine

Additional information from Helm in notification templates and triggers?

Open
#101 6 comments 7 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
334
Forks
217
PR merge metrics
No merged PRs in 30d

Description

Argo version: 2.4.10
Argo helm chart: 4.10.7

## Problem Statement

I'm working on using ArgoCD Notifications to send deployment notifications to slack. I successfully set it up to notify a slack channel on deployment and I have set up the trigger to only on new revisions according to this doc. This works great :+1:

All of our Application objects live in repo A and they point to helm charts for those applications in repo B on the master branch. When we do a deploy, we update the version in a helm values.yaml file in repo B for the appropriate chart. Because this repo is shared between all our applications, argo triggers a deploy notification (and a sync) for all applications. We want to limit these notifications only to the application being deployed. Unfortunately, the `oncePer: app.status.sync.revision` refers to the commit hash of repo B. I'd like to change this to refer to something outside the `app` context.

## Possible solution?

[The docs refer to a few additional bits of data we should have access to in both triggers and templates](https://argo-cd.readthedocs.io/en/stable/operator-manual/notifications/templates/#repo). Accoding to the docs, there should be some helm context available. If I were able to use the version I set in my helm values, I could avoid having to restructure my organization's entire codebase.

I can test this in a slack template and, as best I can understand it, try to fetch the `image.tag` value from the helm values.

```
{
"title": "Helm Version",
"value": "{{repo.GetAppDetails().GetParameterValueByName(\"image.tag\")}}",
"short": true
},
```

However, I get this error when running the template: `failed to create API: template: app-deployed:23: function "repo" not defined`.

Upon further investigation, I'm unable to find anything that would expose this in the code or any of the other documented functions. Admittedly, my golang isn't strong so I may be wrong here. It looks like the context that is passed to the `expr` package that compiles these statements only includes the `Application` object context as `app`. See https://github.com/argoproj/notifications-engine/blob/master/pkg/cmd/trigger.go#L61 and https://github.com/argoproj/notifications-engine/blob/master/pkg/cmd/template.go#L58

## What now?

I'm blocked. When I inspect the `Application` metadata in Kubernetes, the only thing I'm able to find that may differentiate different deployments is `app.status.summary.images[]`. It would be sufficient for now if I could use this to populate `oncePer` in the trigger. However, our devs will eventually want to notify for any deployment unrelated to the image (like a values.yaml update).

Is there something I'm missing? Is there anything as a consumer I can do to make this work?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with pkg/cmd/trigger.go and pkg/cmd/template.go, where the issue says the expr context is limited to the Application as app; compare that with the notification templates documentation for the intended repo and Helm data. Done means templates and triggers can access the needed Helm value or another deployment-specific value so oncePer can distinguish applications sharing a chart repository.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, helm, kubernetes
Domain
devops
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.