Skip to content

[APIE-890] Support iam service accounts list command filtering by display names#3271

Open
Channing Dong (channingdong) wants to merge 2 commits intomainfrom
APIE-890
Open

[APIE-890] Support iam service accounts list command filtering by display names#3271
Channing Dong (channingdong) wants to merge 2 commits intomainfrom
APIE-890

Conversation

@channingdong
Copy link
Contributor

@channingdong Channing Dong (channingdong) commented Feb 27, 2026

Release Notes

Breaking Changes

  • PLACEHOLDER

New Features

  • Add --display-name flag to confluent iam service-account list command.

Bug Fixes

  • PLACEHOLDER

Checklist

  • I have successfully built and used a custom CLI binary, without linter issues from this PR.
  • I have clearly specified in the What section below whether this PR applies to Confluent Cloud, Confluent Platform, or both.
  • I have verified this PR in Confluent Cloud pre-prod or production environment, if applicable.
  • I have verified this PR in Confluent Platform on-premises environment, if applicable.
  • I have attached manual CLI verification results or screenshots in the Test & Review section below.
  • I have added appropriate CLI integration or unit tests for any new or updated commands and functionality.
  • I confirm that this PR introduces no breaking changes or backward compatibility issues.
  • I have indicated the potential customer impact if something goes wrong in the Blast Radius section below.
  • I have put checkmarks below confirming that the feature associated with this PR is enabled in:
    • Confluent Cloud prod
    • Confluent Cloud stag
    • Confluent Platform
    • Check this box if the feature is enabled for certain organizations only

What

According to the OpenAPI reference:
https://docs.confluent.io/cloud/current/api.html#tag/Service-Accounts-(iamv2)/operation/listIamV2ServiceAccounts

display_name is 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:

channingdong@CLK32PJ63L cli % dist/confluent_darwin_arm64_v8.0/confluent iam service-account list
      ID     |                       Name                       |          Description            
-------------+--------------------------------------------------+---------------------------------
  sa-1zv5jv  | app-manager                                      | Service account to manage       
             |                                                  | 'inventory' Kafka cluster       
  sa-38rmpqm | ClusterLink_08c9ae51-f8b5-46c1-bd43-9ec5cd11cad8 | For Cluster Link                
             |                                                  | 'source_to_destination'         
             |                                                  | from source 'lkc-2dy25q' to     
             |                                                  | destination 'lkc-0myxwp'        
  sa-3vz5rj  | app-consumer                                     | Service account to consume      
             |                                                  | from 'orders' topic of          
             |                                                  | 'inventory' Kafka cluster       
  sa-6xpdnq  | env-manager                                      | Service account to manage       
             |                                                  | 'Staging' environment           
  sa-gq0100m | awesome-service-account                          | The first attempt to create     
             |                                                  | resource with auto-generate     
             |                                                  | CLI code                        
  sa-zryok3  | tf_runner                                        | The experimental service        
             |                                                  | account name                   

Filtering by service account Id doesn't work, this is expected:

channingdong@CLK32PJ63L cli % dist/confluent_darwin_arm64_v8.0/confluent iam service-account list --display-name sa-3vz5rj,sa-gq0100m 
None found.

Filtering by service account display names works as expected:

channingdong@CLK32PJ63L cli % dist/confluent_darwin_arm64_v8.0/confluent iam service-account list --display-name awesome-service-account
      ID     |          Name           |          Description            
-------------+-------------------------+---------------------------------
  sa-gq0100m | awesome-service-account | The first attempt to create     
             |                         | resource with auto-generate     
             |                         | CLI code    

Copilot AI review requested due to automatic review settings February 27, 2026 20:38
@confluent-cla-assistant
Copy link

🎉 All Contributor License Agreements have been signed. Ready to merge.
Please push an empty commit if you would like to re-run the checks to verify CLA status for all contributors.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 to iam service-account list and pass values through to the API client call.
  • Extend ccloudv2.Client.ListIamServiceAccounts to accept an optional display-name filter and apply it to the generated request.
  • Update all existing call sites of ListIamServiceAccounts to pass nil (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.

Comment on lines +27 to +31
if err != nil {
return err
}

serviceAccounts, err := c.V2Client.ListIamServiceAccounts(displayNames)
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
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.

2 participants