Skip to content

Commit

Permalink
fix(gcloud_iam): fetch service account resources with pagination (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmatrhd authored Jun 21, 2024
1 parent 8c3e4f1 commit 396f293
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions plugins/providers/gcloudiam/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ func newIamClient(credentialsJSON []byte, resourceName string) (*iamClient, erro
}

func (c *iamClient) ListServiceAccounts(ctx context.Context) ([]*iam.ServiceAccount, error) {
res, err := c.iamService.Projects.ServiceAccounts.List(c.resourceName).Context(ctx).Do()
if err != nil {
serviceAccounts := []*iam.ServiceAccount{}
if err := c.iamService.Projects.ServiceAccounts.List(c.resourceName).Pages(ctx, func(res *iam.ListServiceAccountsResponse) error {
serviceAccounts = append(serviceAccounts, res.Accounts...)
return nil
}); err != nil {
return nil, err
}
return res.Accounts, nil
return serviceAccounts, nil
}

func (c *iamClient) GetGrantableRoles(ctx context.Context, resourceType string) ([]*iam.Role, error) {
Expand Down

0 comments on commit 396f293

Please sign in to comment.