Skip to content

feat(org): Introduce pagination and filtering on ListMemberships#2265

Merged
javirln merged 1 commit into
chainloop-dev:mainfrom
javirln:feat/pfm-3294
Jul 17, 2025
Merged

feat(org): Introduce pagination and filtering on ListMemberships#2265
javirln merged 1 commit into
chainloop-dev:mainfrom
javirln:feat/pfm-3294

Conversation

@javirln

@javirln javirln commented Jul 16, 2025

Copy link
Copy Markdown
Member

This patch updates the OrganizationServiceListMemberships request to support pagination and filtering. The available filters include:

  • Name: Matches against the user’s first or last name
  • Email: Matches against the user’s email address
  • Role: Filters by the user’s role within the organization

The filtering logic applies First Name OR Last Name OR Email, combined with AND Role if the role filter is provided.

@javirln javirln requested review from jiparis and migmartri July 16, 2025 11:33
@javirln javirln self-assigned this Jul 16, 2025
Comment thread app/controlplane/pkg/data/membership.go
Comment thread app/controlplane/api/controlplane/v1/organization.proto
Comment thread app/controlplane/internal/service/organization.go
@javirln javirln marked this pull request as draft July 16, 2025 12:12
@javirln

javirln commented Jul 16, 2025

Copy link
Copy Markdown
Member Author

Add pagination to the CLI with the available filters:

$ chainloop org member ls --limit 10
WRN API contacted in insecure mode
┌──────────────────────────────────────┬───────────────────────────────────────────────────┬────────┬─────────────────────┐
│ ID                                   │ EMAIL                                             │ ROLE   │ JOINED AT           │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441010 │ Isabella Martinez <isabella.martinez@example.com> │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441001 │ John Smith <john.smith@example.com>               │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441002 │ Emma Johnson <emma.johnson@example.com>           │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441003 │ Michael Williams <michael.williams@example.com>   │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441005 │ James Jones <james.jones@example.com>             │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441006 │ Olivia Garcia <olivia.garcia@example.com>         │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441007 │ William Miller <william.miller@example.com>       │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441008 │ Ava Davis <ava.davis@example.com>                 │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441009 │ Robert Rodriguez <robert.rodriguez@example.com>   │ member │ 16 Jul 25 13:55 UTC │
├──────────────────────────────────────┼───────────────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441011 │ David Hernandez <david.hernandez@example.com>     │ member │ 16 Jul 25 13:55 UTC │
└──────────────────────────────────────┴───────────────────────────────────────────────────┴────────┴─────────────────────┘
INF Showing [1-10] out of 144
INF Next page available: 2
$ chainloop org member ls --name elena
WRN API contacted in insecure mode
┌──────────────────────────────────────┬─────────────────────────────────────────┬────────┬─────────────────────┐
│ ID                                   │ EMAIL                                   │ ROLE   │ JOINED AT           │
├──────────────────────────────────────┼─────────────────────────────────────────┼────────┼─────────────────────┤
│ 650e8400-e29b-41d4-a716-446655441126 │ Elena Palmer <elena.palmer@example.com> │ member │ 16 Jul 25 13:55 UTC │
└──────────────────────────────────────┴─────────────────────────────────────────┴────────┴─────────────────────┘
INF Showing [1-1] out of 1
$ chainloop org member ls --role owner
WRN API contacted in insecure mode
┌──────────────────────────────────────┬───────────────────────┬───────┬─────────────────────┐
│ ID                                   │ EMAIL                 │ ROLE  │ JOINED AT           │
├──────────────────────────────────────┼───────────────────────┼───────┼─────────────────────┤
│ 5ed22627-bb66-488d-b78c-04a7ebc10979 │ sarah@chainloop.local │ owner │ 16 Jul 25 10:57 UTC │
└──────────────────────────────────────┴───────────────────────┴───────┴─────────────────────┘
INF Showing [1-1] out of 1
$ chainloop org member ls --role admin
WRN API contacted in insecure mode
┌────┬───────┬──────┬───────────┐
│ ID │ EMAIL │ ROLE │ JOINED AT │
├────┼───────┼──────┼───────────┤
└────┴───────┴──────┴───────────┘

A new membership_id filter was added to support the membership_delete operation. Since there’s no dedicated “get” endpoint, we needed a way to filter memberships by ID without iterating over the entire list.

@javirln javirln marked this pull request as ready for review July 16, 2025 14:19
Comment thread app/controlplane/pkg/data/membership.go Outdated
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
@javirln javirln merged commit 17dbde7 into chainloop-dev:main Jul 17, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants