Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 16 commits intomainfromstevenmasley/user_cli_suspend_2
May 16, 2022

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedMay 13, 2022
edited
Loading

coder users activate <username | user_id>coder users suspend <username | user_id>

@codecov
Copy link

codecovbot commentedMay 13, 2022
edited
Loading

Codecov Report

Merging#1422 (2ed4249) intomain (64a8b4a) willincrease coverage by0.12%.
The diff coverage is75.57%.

@@            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
FlagCoverage Δ
unittest-go-macos-latest54.42% <75.57%> (+0.35%)⬆️
unittest-go-postgres-65.71% <75.57%> (+0.23%)⬆️
unittest-go-ubuntu-latest56.80% <75.57%> (+0.17%)⬆️
unittest-go-windows-202252.78% <75.57%> (+0.37%)⬆️
unittest-js74.73% <ø> (+0.08%)⬆️
Impacted FilesCoverage Δ
coderd/users.go61.80% <57.14%> (+0.36%)⬆️
cli/userstatus.go70.00% <70.00%> (ø)
codersdk/users.go65.12% <84.61%> (+1.33%)⬆️
cli/userlist.go71.42% <100.00%> (-11.43%)⬇️
cli/users.go100.00% <100.00%> (ø)
coderd/coderd.go94.65% <100.00%> (+0.06%)⬆️
cli/autostart.go66.37% <0.00%> (-8.92%)⬇️
cli/autostop.go66.37% <0.00%> (-8.63%)⬇️
peerbroker/dial.go77.04% <0.00%> (-6.56%)⬇️
site/src/components/Section/Section.tsx61.11% <0.00%> (-5.56%)⬇️
... and32 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update64a8b4a...2ed4249. Read thecomment docs.

@EmyrkEmyrk requested review fromkylecarbs andf0sselMay 13, 2022 16:02
}

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Should we changeUser to be this instead of creating a new handler? It seems likeUser is just wrong right now.

Copy link
Member

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.

Copy link
MemberAuthor

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 😢

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I thought about changingUser, then you have to doclient.User(id.String()) because it can't take auuid.
I can't even make it take aStringer becausestring isn't aStringer. I hit this trying to make it "generic" in some way, and kept falling short.

Copy link
Member

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 keepUser with the UUID and addUserByUsername then.UserByIdentifier tells us very little about what the identifier is.

@EmyrkEmyrk requested a review fromkylecarbsMay 13, 2022 18:07
@ammario
Copy link
Member

ammario commentedMay 13, 2022
edited
Loading

Thoughts on outdenting it tocoder users activate <user> andcoder users suspend <user>?

My thinking isstatus is a broad term and it's not immediately obvious it has to do with activation. For example, one may think it has to do with roles or email verification.

@Emyrk
Copy link
MemberAuthor

Thoughts on outdenting it tocoder users activate <user> andcoder users suspend <user>?

My thinking isstatus is a broad term and it's not immediately obvious it has to do with activation. For example, one may think it has to do with roles or email verification.

I'm cool with that. I had that originally, but don't have a strong opinion either way.

@missknissmisskniss added this to theV2 Beta milestoneMay 15, 2022
}

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) {
Copy link
Member

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 keepUser with the UUID and addUserByUsername then.UserByIdentifier tells us very little about what the identifier is.

@Emyrk
Copy link
MemberAuthor

The annoying thing aboutUserByUsername andUser, is that in the cli, it's easier to just take the input as is.

If we haveUser(id) andUserByUsername(name), then it feels weird to have the code pass thearg[0] which can be either a uuid, or a username.

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.

@kylecarbs
Copy link
Member

Fair enough. I don't think doinguuid.String() is bad. It represents what we do internally anyways. Having multiple methods that do the exact same thing seems worse.

@Emyrk
Copy link
MemberAuthor

Fair enough. I don't think doinguuid.String() is bad. It represents what we do internally anyways. Having multiple methods that do the exact same thing seems worse.

The nasty thing would be to accept anany and do afmt.Sprint to get it'sString(). Super annoyingstring does not implementStringer

I'll useUser(ctx, string) and callid.String() where used now

kylecarbs reacted with thumbs up emoji

@Emyrk
Copy link
MemberAuthor

This is werid nowclient.User(cmd.Context(), codersdk.Me.String()). :(

@kylecarbs
Copy link
Member

We could just makecodersdk.Me a string!

Emyrk reacted with thumbs up emoji

@EmyrkEmyrk requested a review fromkylecarbsMay 16, 2022 20:22
Copy link
Member

@kylecarbskylecarbs left a 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),
Copy link
Member

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!

@EmyrkEmyrk merged commitb55d83c intomainMay 16, 2022
@EmyrkEmyrk deleted the stevenmasley/user_cli_suspend_2 branchMay 16, 2022 20:29
kylecarbs pushed a commit that referenced this pull requestJun 10, 2022
* feat: Add suspend/active user to cli* UserID is now a string and allows for username too
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@kylecarbskylecarbskylecarbs approved these changes

@f0sself0sselAwaiting requested review from f0ssel

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
Community MVP
Development

Successfully merging this pull request may close these issues.

4 participants
@Emyrk@ammario@kylecarbs@misskniss

[8]ページ先頭

©2009-2025 Movatter.jp