applicationset
applicationset copied to clipboard
[Proposal]: Git Branch generator
We recently started to use Argo CD as a deployment tool. After checking the application set, we believe it's a nice addition to have "Git Branch" generator.
I can work on the implementation myself, and I believe this will be a nice good first contribution. This issue is more to discuss the spec and the behavior (as well as how we should name things).
Similar to file and directory generator, we propose to have branch generator, could looks something like this:
generators:
- git:
repoURL: [email protected]:something/something.git
revision: "HEAD"
branches:
- dev-*
- feat/*
This generator should yield a param for each branch that matches the glob.
For example, if the repository contains these branches:
- main
- dev-test1
- dev-tes2
- feat/new_feature
For each branch that matches the glob, the generator should yield these parameters:
-
branch.fullname
: The full branch name, e.g dev-test1 and feat/new_feature -
glob
(help with better name): The piece that matches the asterisk, e.g test1 and new_feature
The generator should yield:
{"branch.fullname": "dev-test1", "glob": "test1"}
{"branch.fullname": "dev-test2", "glob": "test2"}
{"branch.fullname": "feat/new_feature", "glob": "new_feature"}
Sanitize branch name
We can also do something similar to cluster generator https://github.com/argoproj-labs/applicationset/pull/237 and just sanitize the branch name and yield it (along with the original name)
{"branch.fullname": "feat/new_feature", "branch.sanitizedName": "feat-new-feature"}
Use case:
This allows developer to create a new Argo CD application by creating a new branch.
Full example
apiVersion: argoproj.io/v1alpha2 # Notice the v1alpha2 ;)
kind: ApplicationSet
metadata:
name: dev-envs
spec:
generators:
- git:
repoURL: [email protected]:something/something.git
revision: "HEAD" # Not really needed for this generator, but it's a required field.
branches:
- deploy/product/dev-*
template:
metadata:
name: '{{glob}}' # We use `glob` instead of `branch.fullname` as the fullname can contain invalid characters
spec:
project: myproject
source:
repoURL: [email protected]:something/something.git
targetRevision: '{{branch.fullname}}'
path: 'charts/product'
helm:
valueFiles:
- values.yaml
destination:
server: https://kubernetes.default.svc
namespace: 'product-{{glob}}'
I would appreciate any feedback on this. I already have a working example as a POC, getting your feedback on the parameter names, what else we can yield is appreciated.
I think this awesome idea. So this makes applicationset a perfect tool to create/delete preview environments!
Agree with @alexmt, this sounds very useful.
I think my only suggestions would be:
-
glob
->globMatch
(just to make it clear that the user is getting the value that the glob matched) -
branch.sanitizedName
=>branch.normalizedName
(normalized, as the verb, rather than sanitized. We do use sanitized in the code itself, but I think normalized is probably a bit better here)
This would be awesome!
Agree @benjamink! Game changer for our workflow
I would also love this!
This would be perfect and exactly what I am looking for! Any idea of when this can be available?
Seems like a dup of #200
Could this be achieved by adding a branch name filter to the SCM provider generator? https://github.com/argoproj/applicationset/blob/master/docs/Generators-SCM-Provider.md#filters
@crenshaw-dev yes, but kinda overkill with scanning for all the repos matching repositoryMatch
and easy to get rate limited unless #565 which fixes credentials is implemented
Hi all! Any news about this one? I assumed that this was implemented already when reading about git generator, and right now it only supports listing directories and files. That would be amazing as it will allow to implement ephemeral environments for feature branches very easily.
@crenshaw-dev yes, but kinda overkill with scanning for all the repos matching
repositoryMatch
and easy to get rate limited unless #565 which fixes credentials is implemented
Looks that this is implemented already!
Hi @Segflow, did you close this because you managed to get this working with the SCM provider generator? The git generator allows you to template based on directories within the repo which I don't think the SCM provider does, so I'm curious if you managed to overcome this
@JS-Jake I think it's a dup of #200