Skip to content

Commit

Permalink
add resolvers for optional target service account and team instead of…
Browse files Browse the repository at this point in the history
… returning ID/slug
  • Loading branch information
christeredvartsen committed Feb 8, 2024
1 parent 7ba5cd3 commit 50105f9
Show file tree
Hide file tree
Showing 21 changed files with 465 additions and 138 deletions.
59 changes: 59 additions & 0 deletions internal/database/gensql/mock_querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/database/gensql/querier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions internal/database/gensql/service_accounts.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions internal/database/mock_database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions internal/database/queries/service_accounts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ WHERE id = @id;
SELECT * FROM service_account_roles
WHERE service_account_id = @service_account_id
ORDER BY role_name ASC;

-- name: GetServiceAccountsByIDs :many
SELECT * FROM service_accounts
WHERE id = ANY(@ids::uuid[])
ORDER BY name ASC;
15 changes: 15 additions & 0 deletions internal/database/service_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type ServiceAccountRepo interface {
GetServiceAccountByName(ctx context.Context, name string) (*ServiceAccount, error)
GetServiceAccountRoles(ctx context.Context, serviceAccountID uuid.UUID) ([]*authz.Role, error)
GetServiceAccounts(ctx context.Context) ([]*ServiceAccount, error)
GetServiceAccountsByIDs(ctx context.Context, ids []uuid.UUID) ([]*ServiceAccount, error)
RemoveAllServiceAccountRoles(ctx context.Context, serviceAccountID uuid.UUID) error
RemoveApiKeysFromServiceAccount(ctx context.Context, serviceAccountID uuid.UUID) error
}
Expand Down Expand Up @@ -78,6 +79,20 @@ func (d *database) GetServiceAccounts(ctx context.Context) ([]*ServiceAccount, e
return serviceAccounts, nil
}

func (d *database) GetServiceAccountsByIDs(ctx context.Context, ids []uuid.UUID) ([]*ServiceAccount, error) {
rows, err := d.querier.GetServiceAccountsByIDs(ctx, ids)
if err != nil {
return nil, err
}

serviceAccounts := make([]*ServiceAccount, 0)
for _, row := range rows {
serviceAccounts = append(serviceAccounts, &ServiceAccount{ServiceAccount: row})
}

return serviceAccounts, nil
}

func (d *database) DeleteServiceAccount(ctx context.Context, serviceAccountID uuid.UUID) error {
return d.querier.DeleteServiceAccount(ctx, serviceAccountID)
}
Expand Down
3 changes: 1 addition & 2 deletions internal/graph/authentication.resolvers.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 50105f9

Please sign in to comment.