Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced templating for ApplicationSet #9961

Closed
speedfl opened this issue Jul 12, 2022 · 3 comments · Fixed by #10026
Closed

Advanced templating for ApplicationSet #9961

speedfl opened this issue Jul 12, 2022 · 3 comments · Fixed by #10026
Labels
component:application-sets Bulk application management related enhancement New feature or request

Comments

@speedfl
Copy link
Contributor

speedfl commented Jul 12, 2022

Summary

Currently ApplicationSet template is using https://github.com/valyala/fasttemplate. But it does not provide advanced templating feature which can be useful for inline helm values

Motivation

When using inline helm values it could be nice to have templating capabilities such as loop, if etc

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: guestbook
  namespace: argocd
spec:
  generators:
  - git:
      repoURL: https://github.com/argoproj/argo-cd.git
      revision: HEAD
      files:
      - path: "applicationset/examples/git-generator-files-discovery/cluster-config/**/config.json"
  template:
    metadata:
      name: '{{cluster.name}}-guestbook'
    spec:
      project: default
      source:
        repoURL: https://github.com/argoproj/argo-cd.git
        targetRevision: HEAD
        path: "applicationset/examples/git-generator-files-discovery/apps/guestbook"
      destination:
        server: '{{cluster.address}}'
        namespace: guestbook
      helm:
        values: |
          fieldWithIf: {{#isOk}}{{myOkValue}}{{/isOk}}{{^isOk}}{{myNonOkValue}}{{/isOk}}
          fieldWithLoop
          {{#elements}}
            - name: {{elements.name}}
              value: {{elements.value}}
          {{/elements}}

Proposal

Use Advanced templating such as Mustache. I am opened to work on a PR using https://github.com/hoisie/mustache

@speedfl speedfl added the enhancement New feature or request label Jul 12, 2022
@todaywasawesome
Copy link
Contributor

Would this allow setting default values? That would be HUGE.

@crenshaw-dev
Copy link
Member

There's a PR to do something similar: #9873

I would like to see that PR drop fasttemplate support, since it's no longer being developed.

I'd rather use Go text templating with Sprig functions rather than Mustache. The Argo suite already makes use of a lot of different template languages/styles. I think keeping it close to the Go ecosystem is advisable.

@crenshaw-dev
Copy link
Member

crenshaw-dev commented Jul 13, 2022

Oh! That PR is for full-template templating. If you only want it per-field, it should be much easier. I'd still advise using Go text templates rather than Mustache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:application-sets Bulk application management related enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants