diff --git a/cli/cliui/filter.go b/cli/cliui/filter.go index a496a8614e..f361018090 100644 --- a/cli/cliui/filter.go +++ b/cli/cliui/filter.go @@ -5,7 +5,7 @@ import ( "github.com/coder/serpent" ) -var defaultQuery = "owner:me" +var defaultQuery = "user:me" // WorkspaceFilter wraps codersdk.WorkspaceFilter // and allows easy integration to a CLI command. diff --git a/cli/list.go b/cli/list.go index 8b4c56edbc..00e43a212e 100644 --- a/cli/list.go +++ b/cli/list.go @@ -129,7 +129,7 @@ func (r *RootCmd) list() *serpent.Command { workspaceFilter.SharedWithUser = user.ID.String() // Unset the default query that conflicts with the --shared-with-me flag - if workspaceFilter.FilterQuery == "owner:me" { + if workspaceFilter.FilterQuery == "user:me" { workspaceFilter.FilterQuery = "" } } diff --git a/cli/list_test.go b/cli/list_test.go index 19e9370a98..4b74a108bb 100644 --- a/cli/list_test.go +++ b/cli/list_test.go @@ -127,24 +127,41 @@ func TestList(t *testing.T) { ctx := testutil.Context(t, testutil.WaitMedium) - client.UpdateWorkspaceACL(ctx, sharedWorkspace.ID, codersdk.UpdateWorkspaceACL{ + // Share orgOwner's workspace with member + err := client.UpdateWorkspaceACL(ctx, sharedWorkspace.ID, codersdk.UpdateWorkspaceACL{ UserRoles: map[string]codersdk.WorkspaceRole{ member.ID.String(): codersdk.WorkspaceRoleUse, }, }) + require.NoError(t, err) - inv, root := clitest.New(t, "list", "--shared-with-me", "--output=json") + // member should see the workspace with the default filter + inv, root := clitest.New(t, "list", "--output=json") clitest.SetupConfig(t, memberClient, root) stdout := new(bytes.Buffer) inv.Stdout = stdout - err := inv.WithContext(ctx).Run() + err = inv.WithContext(ctx).Run() require.NoError(t, err) var workspaces []codersdk.Workspace require.NoError(t, json.Unmarshal(stdout.Bytes(), &workspaces)) require.Len(t, workspaces, 1) require.Equal(t, sharedWorkspace.ID, workspaces[0].ID) + + // member should see the workspace when passing `--shared-with-me` + inv, root = clitest.New(t, "list", "--shared-with-me", "--output=json") + clitest.SetupConfig(t, memberClient, root) + + stdout = new(bytes.Buffer) + inv.Stdout = stdout + err = inv.WithContext(ctx).Run() + require.NoError(t, err) + + workspaces = nil + require.NoError(t, json.Unmarshal(stdout.Bytes(), &workspaces)) + require.Len(t, workspaces, 1) + require.Equal(t, sharedWorkspace.ID, workspaces[0].ID) }) t.Run("HTMLResponse", func(t *testing.T) { diff --git a/cli/testdata/coder_list_--help.golden b/cli/testdata/coder_list_--help.golden index e5afbc02ca..22dfc601a5 100644 --- a/cli/testdata/coder_list_--help.golden +++ b/cli/testdata/coder_list_--help.golden @@ -17,7 +17,7 @@ OPTIONS: -o, --output table|json (default: table) Output format. - --search string (default: owner:me) + --search string (default: user:me) Search for a workspace with a query. ——— diff --git a/cli/testdata/coder_schedule_show_--help.golden b/cli/testdata/coder_schedule_show_--help.golden index 5e1de846bd..2e4344fe83 100644 --- a/cli/testdata/coder_schedule_show_--help.golden +++ b/cli/testdata/coder_schedule_show_--help.golden @@ -21,7 +21,7 @@ OPTIONS: -o, --output table|json (default: table) Output format. - --search string (default: owner:me) + --search string (default: user:me) Search for a workspace with a query. ——— diff --git a/docs/reference/cli/external-workspaces_list.md b/docs/reference/cli/external-workspaces_list.md index 1daf5b2b5b..d00375f4cb 100644 --- a/docs/reference/cli/external-workspaces_list.md +++ b/docs/reference/cli/external-workspaces_list.md @@ -30,10 +30,10 @@ Specifies whether all workspaces will be listed or not. ### --search -| | | -|---------|-----------------------| -| Type | string | -| Default | owner:me | +| | | +|---------|----------------------| +| Type | string | +| Default | user:me | Search for a workspace with a query. diff --git a/docs/reference/cli/list.md b/docs/reference/cli/list.md index 0878cb73c7..8324fa8f72 100644 --- a/docs/reference/cli/list.md +++ b/docs/reference/cli/list.md @@ -30,10 +30,10 @@ Specifies whether all workspaces will be listed or not. ### --search -| | | -|---------|-----------------------| -| Type | string | -| Default | owner:me | +| | | +|---------|----------------------| +| Type | string | +| Default | user:me | Search for a workspace with a query. diff --git a/docs/reference/cli/schedule_show.md b/docs/reference/cli/schedule_show.md index d4e0732836..2403794acd 100644 --- a/docs/reference/cli/schedule_show.md +++ b/docs/reference/cli/schedule_show.md @@ -37,10 +37,10 @@ Specifies whether all workspaces will be listed or not. ### --search -| | | -|---------|-----------------------| -| Type | string | -| Default | owner:me | +| | | +|---------|----------------------| +| Type | string | +| Default | user:me | Search for a workspace with a query. diff --git a/enterprise/cli/testdata/coder_external-workspaces_list_--help.golden b/enterprise/cli/testdata/coder_external-workspaces_list_--help.golden index 1210bea5aa..7242b3f132 100644 --- a/enterprise/cli/testdata/coder_external-workspaces_list_--help.golden +++ b/enterprise/cli/testdata/coder_external-workspaces_list_--help.golden @@ -17,7 +17,7 @@ OPTIONS: -o, --output table|json (default: table) Output format. - --search string (default: owner:me) + --search string (default: user:me) Search for a workspace with a query. ———