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

(appset) Filtering by title on Pull Request generator #16447

Open
jjsiv opened this issue Nov 24, 2023 · 7 comments · May be fixed by #17907
Open

(appset) Filtering by title on Pull Request generator #16447

jjsiv opened this issue Nov 24, 2023 · 7 comments · May be fixed by #17907
Labels
component:applications-set Bulk application management related enhancement New feature or request

Comments

@jjsiv
Copy link
Contributor

jjsiv commented Nov 24, 2023

Summary

Currently it is only possible to filter pull requests with the PR generator by target and source branches (also labels in case of Github and Gitlab). I think it would be nice to be able to do some filtering based on the PR title - especially for Git providers such as Bitbucket Server which do not support labels.

Motivation

We use Bitbucket Server and currently we can only filter pull requests based on the source/target branch. Sometimes we would like to perform other actions on the PR before it is picked up by ArgoCD, but as source/target branches are immutable and Bitbucket doesn't support labels, we have no option to do that. Filtering based on the title would allow us to configure ArgoCD to only pick PRs with particular keywords.

Proposal

I can have a look into this

@crenshaw-dev
Copy link
Collaborator

Rather than adding a new filter, I think we can take advantage of the existing post-selector.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: guestbook
spec:
  goTemplate: true
  generators:
  - pullRequest:
      github:
        owner: myorg
        repo: myrepository
    values:
      titleMatches: '{{ regexMatch "some-regex" .title }}'
    selector:
      matchLabels:
        values.titleMatches: "true"

I haven't tested this, but seems like it should work. We'd still need to add the title parameter, but we'd avoid the new filter field.

@jjsiv
Copy link
Contributor Author

jjsiv commented Nov 30, 2023

Indeed, that could be a solution as well. I will try it out locally later and see how it goes

@llavaud
Copy link

llavaud commented Dec 1, 2023

Rather than adding a new filter, I think we can take advantage of the existing post-selector.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: guestbook
spec:
  goTemplate: true
  generators:
  - pullRequest:
      github:
        owner: myorg
        repo: myrepository
    values:
      titleMatches: '{{ regexMatch "some-regex" .title }}'
    selector:
      matchLabels:
        values.titleMatches: "true"

I haven't tested this, but seems like it should work. We'd still need to add the title parameter, but we'd avoid the new filter field.

I don't see the values bloc in the doc neither in the ApplicationSet spec...

@crenshaw-dev
Copy link
Collaborator

crenshaw-dev commented Dec 1, 2023

Ah, we need to add that values field to all generators. Try this.

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: guestbook
spec:
  goTemplate: true
  generators:
  - matrix:
      generators:
      - pullRequest:
          github:
            owner: myorg
            repo: myrepository
      - list:
          elements:
          - titleMatches: '{{ regexMatch "some-regex" .title }}'
    selector:
      matchLabels:
       titleMatches: "true"

@crenshaw-dev
Copy link
Collaborator

Just tested, and that actually works.

@ggjulio
Copy link

ggjulio commented Feb 22, 2024

It seem that the title key is currently not available on argocd 2.10.1

image

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: preview
  namespace: argocd
spec:
  goTemplate: true
  goTemplateOptions: ["missingkey=error"]
  generators:
  - matrix:
      generators:
      - pullRequest:
            bitbucketServer:
              project: project-name
              repo: repo-name
              api: https://bitbucket.example.com
              basicAuth:
                // ...
       - list:
            elements:
            - titleMatches: '{{ regexMatch "some-regex" .title }}'
    selector:
      matchLabels:
       titleMatches: "true"
template:
  // ...

@jgwest jgwest added the component:applications-set Bulk application management related label Mar 29, 2024
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 19, 2024
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 19, 2024
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 20, 2024
@ggjulio ggjulio linked a pull request Apr 20, 2024 that will close this issue
11 tasks
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 20, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 20, 2024
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 20, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 20, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 20, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 20, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 20, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 21, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
@ggjulio
Copy link

ggjulio commented Apr 22, 2024

Rather than adding a new filter, I think we can take advantage of the existing post-selector.

I haven't tested this, but seems like it should work. We'd still need to add the title parameter, but we'd avoid the new filter field.

A PR adding the title parameter is ready for review #17907

ggjulio added a commit to ggjulio/argo-cd that referenced this issue Apr 23, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component:applications-set Bulk application management related enhancement New feature or request
Projects
None yet
5 participants