Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Closed
jjsiv opened this issue Nov 24, 2023 · 7 comments · Fixed by #17907
Closed

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

jjsiv opened this issue Nov 24, 2023 · 7 comments · Fixed by #17907
Labels
component:application-sets 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
Member

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
Member

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
Member

Just tested, and that actually works.

@ggjulio
Copy link
Contributor

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:application-sets 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 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
Contributor

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>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Jun 6, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Jun 7, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Jun 12, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Jul 21, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ggjulio added a commit to ggjulio/argo-cd that referenced this issue Jul 21, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
ishitasequeira pushed a commit that referenced this issue Jul 22, 2024
Signed-off-by: ggjulio <juligonz@student.42.fr>
vfaergestad pushed a commit to vfaergestad/argo-cd that referenced this issue Jul 22, 2024
…j#17907)

Signed-off-by: ggjulio <juligonz@student.42.fr>
Signed-off-by: Vegard Færgestad <vegardf@mnemonic.no>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
component:application-sets Bulk application management related enhancement New feature or request
Projects
None yet
5 participants