-
Notifications
You must be signed in to change notification settings - Fork 905
feat: Add suspend/active user to cli #1422
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1422 +/- ##
==========================================
+ Coverage 67.07% 67.19% +0.12%
==========================================
Files 287 292 +5
Lines 19307 19612 +305
Branches 241 258 +17
==========================================
+ Hits 12950 13179 +229
- Misses 5016 5079 +63
- Partials 1341 1354 +13
Continue to review full report at Codecov.
|
codersdk/users.go
Outdated
} | ||
|
||
func (c *Client) userByIdentifier(ctx context.Context, ident string) (User, error) { | ||
// UserByIdentifier returns a user for the username or uuid provided. | ||
func (c *Client) UserByIdentifier(ctx context.Context, ident string) (User, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we change User
to be this instead of creating a new handler? It seems like User
is just wrong right now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all /users/<param>
routes, we could create a generic that accepts a string or UUID. Right now it's incorrectly stated that they require UUIDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to make a generic, but unfortunately you cannot make struct methods generics 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about changing User
, then you have to do client.User(id.String())
because it can't take a uuid
.
I can't even make it take a Stringer
because string
isn't a Stringer
. I hit this trying to make it "generic" in some way, and kept falling short.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'd rather just keep User
with the UUID and add UserByUsername
then. UserByIdentifier
tells us very little about what the identifier is.
Thoughts on outdenting it to My thinking is |
I'm cool with that. I had that originally, but don't have a strong opinion either way. |
codersdk/users.go
Outdated
} | ||
|
||
func (c *Client) userByIdentifier(ctx context.Context, ident string) (User, error) { | ||
// UserByIdentifier returns a user for the username or uuid provided. | ||
func (c *Client) UserByIdentifier(ctx context.Context, ident string) (User, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'd rather just keep User
with the UUID and add UserByUsername
then. UserByIdentifier
tells us very little about what the identifier is.
The annoying thing about If we have The appropriate code would be to try and parse the arg as a uuid, and if it fails, try as a username. But the api already does that, and it seems excessive to check locally as well. So having a function accept either is useful when just passing input along. |
Fair enough. I don't think doing |
The nasty thing would be to accept an I'll use |
This is werid now |
We could just make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. User changes are really nice!
|
||
// Prompt to confirm the action | ||
_, err = cliui.Prompt(cmd, cliui.PromptOptions{ | ||
Text: fmt.Sprintf("Are you sure you want to %s this user?", verb), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of this verb is really nice here!
* feat: Add suspend/active user to cli * UserID is now a string and allows for username too
Uh oh!
There was an error while loading. Please reload this page.