[APIE-890] Support iam service accounts list command filtering by display names#3271
[APIE-890] Support iam service accounts list command filtering by display names#3271Channing Dong (channingdong) wants to merge 2 commits intomainfrom
Conversation
…ter for the display name
|
🎉 All Contributor License Agreements have been signed. Ready to merge. |
There was a problem hiding this comment.
Pull request overview
Adds support for filtering confluent iam service-account list results by service account display name, wiring the CLI flag through to the IAM v2 List Service Accounts API query parameter.
Changes:
- Add
--display-name(StringSlice) flag toiam service-account listand pass values through to the API client call. - Extend
ccloudv2.Client.ListIamServiceAccountsto accept an optional display-name filter and apply it to the generated request. - Update all existing call sites of
ListIamServiceAccountsto passnil(no filtering).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/flags.go | Updates service account autocomplete to use the new ListIamServiceAccounts(nil) signature. |
| pkg/ccloudv2/iam.go | Adds display-name filtering support to service account list pagination/request construction. |
| internal/ksql/command_cluster_create.go | Adapts to new ListIamServiceAccounts(nil) signature for SA lookups. |
| internal/iam/command_service_account_list.go | Introduces --display-name flag and uses it to filter results. |
| internal/iam/command_rbac_role_binding_list.go | Adapts to new ListIamServiceAccounts(nil) signature for SA name mapping. |
| internal/iam/command.go | Adapts to new ListIamServiceAccounts(nil) signature for owner autocomplete. |
| internal/flink/command_statement_update.go | Adapts to new ListIamServiceAccounts(nil) signature for principal autocomplete. |
| internal/api-key/command_list.go | Adapts to new ListIamServiceAccounts(nil) signature for SA resolution. |
| internal/api-key/command_describe.go | Adapts to new ListIamServiceAccounts(nil) signature for SA resolution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| serviceAccounts, err := c.V2Client.ListIamServiceAccounts(displayNames) |
There was a problem hiding this comment.
The new --display-name filtering behavior isn’t covered by the existing CLI integration tests. There are already golden tests for iam service-account list, so please add a new test case exercising iam service-account list --display-name ... and update the test server handler for /iam/v2/service-accounts to honor the display_name query param so the test can actually validate filtering (not just ignore the param).
Release Notes
Breaking Changes
New Features
--display-nameflag toconfluent iam service-account listcommand.Bug Fixes
Checklist
Whatsection below whether this PR applies to Confluent Cloud, Confluent Platform, or both.Test & Reviewsection below.Blast Radiussection below.What
According to the OpenAPI reference:
https://docs.confluent.io/cloud/current/api.html#tag/Service-Accounts-(iamv2)/operation/listIamV2ServiceAccounts
display_nameis supported as a MultipleSearchFilter and should allow selective filtering of the target service accounts, but the CLI currently does not support it.This PR adds support for filtering by display_name by wiring it into the existing implementation.
Blast Radius
Almost none, as this is additive + optional flag and users can still skip setting the flag to retrieve all service accounts.
References
Test & Review
The original list command without setting the flag is unaffected:
Filtering by service account Id doesn't work, this is expected:
Filtering by service account display names works as expected: