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
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

feat: Option to list all workspaces#416

Merged
cdrci merged 5 commits intocoder:masterfromgoodspark:ls-all-workspaces
Aug 12, 2021

Conversation

goodspark
Copy link
Contributor

From an admin POV, this will be helpful for various reasons.

kylecarbs, sreya, deansheather, and coadler reacted with heart emoji
From an admin POV, this will be helpful for various reasons.
{
name: "simple list",
command: []string{"workspaces", "ls", "--all"},
assert: func(r result) { r.success(t) },
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Sanity check: This isn't actually checking the output - just that the command exited with 0?

Copy link
Member

Choose a reason for hiding this comment

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

Essentially, yeah. This mini test framework "runs" the commands in-process and checks if the command fn returned an error.

}
if provider != "" {
if provider != ""|| all{
Copy link
Member

Choose a reason for hiding this comment

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

This means the--all flag only works with the--provider flag. I think that's OK for now, but it needs to be made obvious in the flag description (e.g. "requires --provider flag") and there should be a check at the top of the command to ensure--provider is set if--all is set.

$ ./coder envs ls --allfatal: resource not found

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Doesn't it mean it worksregardless of the provider flag? If I call coder with just--all, provider is "", and the logic becomesif "" != "" || true ->if false || true ->if true. This was my intent - as an admin, I want to seeall workspaces.

But looking at the actual logic/implementation for getWorkspacesByProvider, I think your point still stands. I can fix that.

@deansheather
Copy link
Member

This looks great, just needs a few changes and it'll be solid 😄

@goodsparkgoodspark changed the titleOption to list all workspacesfeat: Option to list all workspacesAug 12, 2021
goodsparkand others added2 commitsAugust 12, 2021 09:12
Co-authored-by: Dean Sheather <dean@deansheather.com>
Comment on lines 96 to 108
} else if provider != "" {
var err error
workspaces, err = getWorkspacesByProvider(ctx, client, provider, user)
if err != nil {
return err
}
} else {
var err error
workspaces, err = getWorkspaces(ctx, client, user)
if err != nil {
return err
}
}
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Shuffled this around because it seemed like the first fetch for the user-only workspaces was ignored if providers was also passed.

kylecarbs reacted with thumbs up emoji
Copy link
Member

@deansheatherdeansheather left a comment

Choose a reason for hiding this comment

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

Seems to work well when I checked out and ran it against our deployment

if provider != "" {
var workspaces []coder.Workspace
if all {
var err error
Copy link
Member

Choose a reason for hiding this comment

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

You shouldn't need thevar errs here or in the other if branches since it's already defined above, then you can condense theif err check to be underneath the if branches, so each branch is just theworkspaces, err = getX() statement.

edit: check my suggestion

goodsparkand others added2 commitsAugust 12, 2021 13:42
Co-authored-by: Dean Sheather <dean@deansheather.com>
@cdrcicdrci merged commitcf9e7e4 intocoder:masterAug 12, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@deansheatherdeansheatherdeansheather approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@goodspark@deansheather@cdrci

[8]ページ先頭

©2009-2025 Movatter.jp