Skip to content

Commit 50105f9

Browse files
add resolvers for optional target service account and team instead of returning ID/slug
1 parent 7ba5cd3 commit 50105f9

21 files changed

+465
-138
lines changed

internal/database/gensql/mock_querier.go

+59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/database/gensql/querier.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/database/gensql/service_accounts.sql.go

+26
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/database/mock_database.go

+59
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/database/queries/service_accounts.sql

+5
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,8 @@ WHERE id = @id;
2424
SELECT * FROM service_account_roles
2525
WHERE service_account_id = @service_account_id
2626
ORDER BY role_name ASC;
27+
28+
-- name: GetServiceAccountsByIDs :many
29+
SELECT * FROM service_accounts
30+
WHERE id = ANY(@ids::uuid[])
31+
ORDER BY name ASC;

internal/database/service_accounts.go

+15
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type ServiceAccountRepo interface {
1717
GetServiceAccountByName(ctx context.Context, name string) (*ServiceAccount, error)
1818
GetServiceAccountRoles(ctx context.Context, serviceAccountID uuid.UUID) ([]*authz.Role, error)
1919
GetServiceAccounts(ctx context.Context) ([]*ServiceAccount, error)
20+
GetServiceAccountsByIDs(ctx context.Context, ids []uuid.UUID) ([]*ServiceAccount, error)
2021
RemoveAllServiceAccountRoles(ctx context.Context, serviceAccountID uuid.UUID) error
2122
RemoveApiKeysFromServiceAccount(ctx context.Context, serviceAccountID uuid.UUID) error
2223
}
@@ -78,6 +79,20 @@ func (d *database) GetServiceAccounts(ctx context.Context) ([]*ServiceAccount, e
7879
return serviceAccounts, nil
7980
}
8081

82+
func (d *database) GetServiceAccountsByIDs(ctx context.Context, ids []uuid.UUID) ([]*ServiceAccount, error) {
83+
rows, err := d.querier.GetServiceAccountsByIDs(ctx, ids)
84+
if err != nil {
85+
return nil, err
86+
}
87+
88+
serviceAccounts := make([]*ServiceAccount, 0)
89+
for _, row := range rows {
90+
serviceAccounts = append(serviceAccounts, &ServiceAccount{ServiceAccount: row})
91+
}
92+
93+
return serviceAccounts, nil
94+
}
95+
8196
func (d *database) DeleteServiceAccount(ctx context.Context, serviceAccountID uuid.UUID) error {
8297
return d.querier.DeleteServiceAccount(ctx, serviceAccountID)
8398
}

internal/graph/authentication.resolvers.go

+1-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)