argoproj / applicationset

The ApplicationSet controller manages multiple Argo CD Applications as a single ApplicationSet unit, supporting deployments to large numbers of clusters, deployments of large monorepos, and enabling secure Application self-service.
https://argocd-applicationset.readthedocs.io/
Apache License 2.0
588 stars 279 forks source link

Merge multiple generators to have a config file per app #262

Open WillooWisp opened 3 years ago

WillooWisp commented 3 years ago

I started experimenting with the matrix generator, in hope of combining the directory generator with a config file per directory, e.g. making it possible to have a specific config.json file per application to generate to be able to specify specific namespace per application, or specific sync settings per application. Is this possible somehow?

generators:
  - matrix:
      generators:
      - git:
          repoURL: git@github.com:Connectitude/iot-infra-k8s.git
          revision: feature/applicationset
          directories:
          - path: "applicationset/cluster-addons/*"
      - git:
          repoURL: git@github.com:Connectitude/iot-infra-k8s.git
          revision: feature/applicationset
          files:
          - path: "applicationset/cluster-configs/{{path.basename}}.json"
jgwest commented 3 years ago

Thanks for the detailed example and explanation, very helpful for visualizing your question. I can't think of a way to do that with the current matrix generator as it exists, but I can definitely see how that would be useful.

Just brainstorming off the top of my head here, not committing to any changes :smile:, but here's a pseudo-example where I could see it working something like this:

generators:
- matrix:
    generators:
    - git:
        repoURL: git@github.com:Connectitude/iot-infra-k8s.git
        revision: feature/applicationset
        directories:
        - path: "applicationset/cluster-addons/*"
      paramPrefix: git_directory. # 'paramPrefix' idea from 236
    - git:
        repoURL: git@github.com:Connectitude/iot-infra-k8s.git
        revision: feature/applicationset
        files:
        - path: "applicationset/cluster-configs/*.json"
      paramPrefix: git_file.        
    # Combine sets of parameters using the matrix generator as usual, BUT only output a set of parameters
    # if it meets this criteria:
    emitParameterIf: # (or maybe call this field join?)
      operandA: git_directory.path.basename
      operator: =
      operandB: git_file.config_file.path.basename # new parameters a bit like 258

Which would depend on at least a few other features being implemented:

So this would still generate every combinaton of parameters between the two generators, BUT it would only emit ones (to the template) that match a specified condition (eg a join). That way applications within the Git directory folder would get matched against corresponding config.json paths.

WillooWisp commented 2 years ago

Is this supported in anyway now?

LeartBeqiraj commented 2 years ago

Is this a supported feature now?