Open sahotay opened 1 year ago
Additional context here: https://github.com/argoproj/argo-cd/pull/9584#pullrequestreview-1059424970
thanks @morey-tech Do you know if this feature got added ? i see this is part of the documentation now but it seems i do get the same error
project refers to the [Argo CD Project](https://argo-cd.readthedocs.io/en/stable/user-guide/projects/) in use (default may be used here to utilize the default Argo CD Project)
@sahotay I believe the spec.template.spec.project
field still can not be templated. Also, the ApplicationSet
documentation has been moved into the Argo CD docs, so this would be the correct page now. That section describes what the spec.template
fields of the ApplicationSet
relate to on an Application
. The docs could use an enhancement to clarify that you can't template that field.
Managed to get around this via generators template:
spec:
generators:
- list:
elements:
- project: serviceentry
extraParam: a
- project: default
extraParam: b
template:
spec:
project: '{{project}}'
template:
spec:
project: default
Project is correctly replaced then.
Managed to get around this via generators template:
spec: generators: - list: elements: - project: serviceentry extraParam: a - project: default extraParam: b template: spec: project: '{{project}}' template: spec: project: default
Project is correctly replaced then.
Is this possible with the git directory generator as well?
@jasperjorna got it working with argocd v2.12.0 like this:
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
name: my-appset
namespace: argocd
spec:
goTemplate: true
goTemplateOptions: ["missingkey=error"]
generators:
- git:
repoURL: my-git-repo
revision: main
files:
- path: applications/*/cluster-a/.argocd.yaml
template:
metadata: {}
spec:
project: '{{ dig "project" "default" . }}' # lookup from .argocd.yaml, defaults to 'default'
destination: {}
template:
metadata:
name: '{{ index .path.segments 1 }}' # the application name
spec:
project: default # will be overriden by git generator's template.spec.project
...
I am using a git generator searching for a specific file, which is a YAML file containing several keys but specific to this issue it has a "project" key.
Hope this helps you / others.
Summary
Is it possible to add feature to create ApplicationSet with templated project files
Error: