authorize: add support for service accounts (#1374)

This commit is contained in:
Caleb Doxsey 2020-09-04 10:37:00 -06:00 committed by GitHub
parent eaf0dd4e67
commit 0a6796ff71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 236 additions and 51 deletions

View file

@ -50,3 +50,17 @@ func Set(ctx context.Context, client databroker.DataBrokerServiceClient, u *User
}
return res.GetRecord(), nil
}
// SetServiceAccount sets a service account in the databroker.
func SetServiceAccount(ctx context.Context, client databroker.DataBrokerServiceClient, sa *ServiceAccount) (*databroker.Record, error) {
any, _ := anypb.New(sa)
res, err := client.Set(ctx, &databroker.SetRequest{
Type: any.GetTypeUrl(),
Id: sa.GetId(),
Data: any,
})
if err != nil {
return nil, fmt.Errorf("error setting service account in databroker: %w", err)
}
return res.GetRecord(), nil
}