argoproj-labs / argocd-autopilot

Argo-CD Autopilot
https://argocd-autopilot.readthedocs.io/en/stable/
Apache License 2.0
899 stars 121 forks source link

Not able to apply annotations in particular application #383

Open NitishGupta9282 opened 2 years ago

NitishGupta9282 commented 2 years ago

Hi,

 I want to apply annotations on application level rather than project level. So i am trying to apply annotations in config.json file of my app, But annotations are not reflecting in UI, Its working fine when i applied annotations on project level. Code is attached below.
    {
  "appName": "sample",
  "userGivenName": "sample",
  "destNamespace": "default",
  "destServer": "https://kubernetes.default.svc",
  "srcPath": "apps/sample/overlays/lab",
  "srcRepoURL": "https://github.com/NitishGupta9282/autop.git",
  "srcTargetRevision": "",
  "labels": null,
  "annotations":
        { 
         "op": "add",
          "test": "sample"
   }
}
philipsens commented 1 month ago

I also wonder how this is supposed to work.

philipsens commented 1 month ago

Add goTemplate: true and add a templatePatch like this:

templatePatch: |
  metadata:
    annotations:
      {{- range $key, $value := .annotations }}
      {{ $key }}: {{ $value }}
      {{- end }}

This works, thanks to https://github.com/argoproj/argo-cd/pull/14893.

It would be nice if this is the default for new Autopilot Applications.