Open dan-vystrcil opened 10 months ago
This is a limitation of the language used to evaluate the template expression. Try this:
.application.metadata.annotations["chartis-file"]
This is a limitation of the language used to evaluate the template expression. Try this:
.application.metadata.annotations["chartis-file"]
It's been a while, but now I am trying to use this for another annotation and unfortunately, your suggestion is not working.
The new error is: Unable to load data: failed to read application deep links from configmap: error unmarshalling deep links error converting YAML to JSON: yaml: did not find expected ',' or '}'
I can't debug further at the moment, so I will fall back on changing the annotation to camelCase since I have control over it.
I've had the exact same issue and found a solution. Try this:
application.links: |
- url: "{{index .application.metadata.annotations \"my.annotations/test-deep-link\"}}"
title: Deep link
if: application.metadata.annotations["my.annotations/test-deep-link"] != ""
Related? I tried using index
in notifications template and it blows things up, e.g.
kind: Application
metadata:
name: foo
annotations:
foo.io/vcs-url: https://github.com/acme/foo
spec:
sources:
- repoURL: https://github.com/acme/foo-config
---
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
...
template.app-deployed: |
message: |
Application {{ .app.metadata.name }} is now running new version of deployments manifests.
github:
repoURLPath: "{{ "defaultValue" | or (index .app.metadata.annotations "foo.io/vcs-url") }}"
which results in a marshalling error no matter what permutation I try to reference the "foo.io/vcs-url" annotation.
ERRO[0000] error getting api from namespace: argocd error: failed to unmarshal template app-deployed: error converting YAML to JSON: yaml: line 3: did not find expected key
failed to get api: errors getting apis: [failed to unmarshal template app-deployed: error converting YAML to JSON: yaml: line 3: did not find expected key]
argocd@argocd-notifications-controller-64bbdf5ffd-vp5ln:/app$ argocd admin notifications template get
ERRO[0000] error getting api from namespace: argocd error: failed
Checklist:
argocd version
.Describe the bug
When adding a deep link and using:
{{.application.metadata.annotations.some/name}}
or{{.application.metadata.annotations.some-name}}
The link will not appear and parsing errors will be logged on the server.
The annotations themselves are valid and will be presented on the application details page.
To Reproduce
Expected behavior
Valid annotations should be honored.
Screenshots
Version
Logs