Skip to content

Commit

Permalink
Merge branch 'feature/avoid-impersonation/binary-only' into feature/a…
Browse files Browse the repository at this point in the history
…void-impersonation/full-stack
  • Loading branch information
philomory committed Feb 11, 2025
2 parents 39b2ee2 + 9f24030 commit 9167e2f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions internal/google/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package google

import (
"context"
"strings"
"errors"
"strings"

"golang.org/x/oauth2/google"
admin "google.golang.org/api/admin/directory/v1"
Expand Down Expand Up @@ -124,13 +124,14 @@ func (c *client) GetUsers(query string) ([]*admin.User, error) {

// The Google api doesn't support multi-part queries, but we do so we need to split into an array of query strings
queries := strings.Split(query, ",")

// Then call the api one query at a time, appending to our list
for _, subQuery := range queries {
err = c.service.Users.List().Query(subQuery).Customer(c.customerId).Pages(c.ctx, func(users *admin.Users) error {
u = append(u, users.Users...)
return nil
})

// Then call the api one query at a time, appending to our list
for _, subQuery := range queries {
err = c.service.Users.List().Query(subQuery).Customer(c.customerId).Pages(c.ctx, func(users *admin.Users) error {
u = append(u, users.Users...)
return nil
})
}
}

// some people prefer to go by a mononym
Expand All @@ -146,9 +147,9 @@ func (c *client) GetUsers(query string) ([]*admin.User, error) {
// Check we've got some users otherwise something is wrong.
if len(u) == 0 {
return u, errors.New("google api returned 0 users?")
}
}
return u, err


}

Expand Down

0 comments on commit 9167e2f

Please sign in to comment.