Checklist:
Describe the bug
argocd admin notifications template notify throws an error when testing a notification that contains a call to .repo.getAppDetails.
To Reproduce
Setup this notification in the argocd-notifications configmap:
$ cat ./argocd-notifications.preprod-eu.yaml
[...]
template.app-sync-succeeded: |
message: |
{{if eq .serviceType "slack"}}:check_ok:{{end}} Deployment <{{.context.argocdUrl}}applications/{{.app.metadata.name}}|{{.app.metadata.name}}> to `{{.context.environmentName}}-{{.context.region}}` environment succeeded!
repository: `{{.app.spec.source.repoURL}}`
{{if ne (index .app.metadata.annotations "release-values-prefix") nil }}
tag: `{{ (call .repo.GetAppDetails).Helm.GetParameterValueByName (print (index .app.metadata.annotations "release-values-prefix") ".app.image.tag") }}`
executor: `{{ (call .repo.GetAppDetails).Helm.GetParameterValueByName (print (index .app.metadata.annotations "release-values-prefix") ".release.lastAuthor") }}`
{{end}}
[...]
Then call the CLI:
# Current kubecontext targets a live cluster and the 'argocd' namespace, which contains an ArgoCD 2.3.3 deployment
$ ./argocd-2.4.14 admin notifications --config-map ./argocd-notifications.preprod-eu.yaml template notify app-sync-succeeded myapp
failed to notify 'console:stdout': template: app-sync-succeeded:4:10: executing "app-sync-succeeded" at <call .repo.GetAppDetails>: error calling call: runtime error: invalid memory address or nil pointer dereference
Expected behavior
I would expect admin notifications template notify to succeed and return the templated text, with the CLI contacting the server to load dynamic data.
Version
ArgoCD server 2.3.3.
Reproduced with any client from 2.3.3 to 2.5.0-rc2.
$ kubectl exec argocd-repo-server-7c946fc856-f2h4x -- argocd version
Defaulted container "repo-server" out of: repo-server, copyutil (init)
argocd: v2.3.3+07ac038
BuildDate: 2022-03-30T00:06:18Z
GitCommit: 07ac038a8f97a93b401e824550f0505400a8c84e
GitTreeState: clean
GoVersion: go1.17.6
Compiler: gc
Platform: linux/amd64
time="2022-10-12T14:45:12Z" level=fatal msg="Argo CD server address unspecified"
command terminated with exit code 1
$ ./argocd-2.4.14 version
argocd: v2.4.14+029be59
BuildDate: 2022-10-05T17:37:30Z
GitCommit: 029be590bfd5003d65ddabb4d4cb8a31bff29c18
GitTreeState: clean
GoVersion: go1.18.6
Compiler: gc
Platform: linux/amd64
FATA[0000] Argo CD server address unspecified
Logs
Client doesn't log anything, didn't find anything related in server logs (I suspect this is entirely client side).
Additional data
- Removing the calls to
.repo.GetAppDetails from the template fixes the calls, but of course prevents testing them.
- It does seem like the CLI contacts the server to load the app: passing a non-existent app name fails with the proper error
applications.argoproj.io "myapp2" not found.
Checklist:
argocd version.Describe the bug
argocd admin notifications template notifythrows an error when testing a notification that contains a call to.repo.getAppDetails.To Reproduce
Setup this notification in the argocd-notifications configmap:
Then call the CLI:
Expected behavior
I would expect
admin notifications template notifyto succeed and return the templated text, with the CLI contacting the server to load dynamic data.Version
ArgoCD server 2.3.3.
Reproduced with any client from 2.3.3 to 2.5.0-rc2.
Logs
Client doesn't log anything, didn't find anything related in server logs (I suspect this is entirely client side).
Additional data
.repo.GetAppDetailsfrom the template fixes the calls, but of course prevents testing them.applications.argoproj.io "myapp2" not found.