mirror of
https://github.com/gravitational/teleport
synced 2024-10-19 08:43:58 +00:00
b60ea81d54
services.UsersService now takes a context and returns the user from write operations as shown in the diff below. The bulk of the changes are from modifying code to account for the additional parameter and/or return value. Functional changes to better make use of the new API will come in follow up PRs. ```diff // UserGetter is responsible for getting users type UserGetter interface { // GetUser returns a user by name - GetUser(user string, withSecrets bool) (types.User, error) + GetUser(ctx context.Context, user string, withSecrets bool) (types.User, error) } // UsersService is responsible for basic user management type UsersService interface { UserGetter // CreateUser creates user, only if the user entry does not exist - CreateUser(user types.User) error + CreateUser(ctx context.Context, user types.User) (types.User, error) // UpdateUser updates an existing user. - UpdateUser(ctx context.Context, user types.User) error + UpdateUser(ctx context.Context, user types.User) (types.User, error) // UpdateAndSwapUser reads an existing user, runs `fn` against it and writes // the result to storage. Return `false` from `fn` to avoid storage changes. // Roughly equivalent to [GetUser] followed by [CompareAndSwapUser]. // Returns the storage user. UpdateAndSwapUser(ctx context.Context, user string, withSecrets bool, fn func(types.User) (changed bool, err error)) (types.User, error) // UpsertUser updates parameters about user - UpsertUser(user types.User) error + UpsertUser(ctx context.Context, user types.User) (types.User, error) // CompareAndSwapUser updates an existing user, but fails if the user does // not match an expected backend value. CompareAndSwapUser(ctx context.Context, new, existing types.User) error // DeleteUser deletes a user with all the keys from the backend DeleteUser(ctx context.Context, user string) error // GetUsers returns a list of users registered with the local auth server - GetUsers(withSecrets bool) ([]types.User, error) + GetUsers(ctx context.Context, withSecrets bool) ([]types.User, error) // DeleteAllUsers deletes all users - DeleteAllUsers() error + DeleteAllUsers(ctx context.Context) error } ``` Depends on gravitational/teleport.e#2346 Implements step 3 of #32949 |
||
---|---|---|
.. | ||
fixtures.go |