- Notifications
You must be signed in to change notification settings - Fork1k
feat: Single query for all workspaces with optional filter#1537
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
c18b162
f0bf934
817bae1
8cc4a2c
67423fb
ba3f15d
3142a22
c1bb602
32cf21f
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -29,7 +29,7 @@ func list() *cobra.Command { | ||
if err != nil { | ||
return err | ||
} | ||
workspaces, err := client.Workspaces(cmd.Context(), codersdk.WorkspaceFilter{}) | ||
Emyrk marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
if err != nil { | ||
return err | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -253,7 +253,6 @@ func New(options *Options) (http.Handler, func()) { | ||
}) | ||
r.Get("/gitsshkey", api.gitSSHKey) | ||
r.Put("/gitsshkey", api.regenerateGitSSHKey) | ||
}) | ||
}) | ||
}) | ||
@@ -289,23 +288,28 @@ func New(options *Options) (http.Handler, func()) { | ||
) | ||
r.Get("/", api.workspaceResource) | ||
}) | ||
r.Route("/workspaces", func(r chi.Router) { | ||
r.Use( | ||
apiKeyMiddleware, | ||
authRolesMiddleware, | ||
) | ||
r.Get("/", api.workspaces) | ||
Emyrk marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
r.Route("/{workspace}", func(r chi.Router) { | ||
r.Use( | ||
httpmw.ExtractWorkspaceParam(options.Database), | ||
) | ||
r.Get("/", api.workspace) | ||
r.Route("/builds", func(r chi.Router) { | ||
r.Get("/", api.workspaceBuilds) | ||
r.Post("/", api.postWorkspaceBuilds) | ||
r.Get("/{workspacebuildname}", api.workspaceBuildByName) | ||
}) | ||
r.Route("/autostart", func(r chi.Router) { | ||
r.Put("/", api.putWorkspaceAutostart) | ||
}) | ||
r.Route("/autostop", func(r chi.Router) { | ||
r.Put("/", api.putWorkspaceAutostop) | ||
}) | ||
}) | ||
}) | ||
r.Route("/workspacebuilds/{workspacebuild}", func(r chi.Router) { | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -78,7 +78,6 @@ func TestAuthorizeAllEndpoints(t *testing.T) { | ||
"GET:/api/v2/workspaceagents/me/metadata": {NoAuthorize: true}, | ||
"GET:/api/v2/workspaceagents/me/turn": {NoAuthorize: true}, | ||
"GET:/api/v2/workspaceagents/{workspaceagent}": {NoAuthorize: true}, | ||
"GET:/api/v2/workspaceagents/{workspaceagent}/dial": {NoAuthorize: true}, | ||
"GET:/api/v2/workspaceagents/{workspaceagent}/iceservers": {NoAuthorize: true}, | ||
"GET:/api/v2/workspaceagents/{workspaceagent}/pty": {NoAuthorize: true}, | ||
@@ -95,7 +94,6 @@ func TestAuthorizeAllEndpoints(t *testing.T) { | ||
"GET:/api/v2/users/oauth2/github/callback": {NoAuthorize: true}, | ||
"PUT:/api/v2/organizations/{organization}/members/{user}/roles": {NoAuthorize: true}, | ||
"GET:/api/v2/organizations/{organization}/provisionerdaemons": {NoAuthorize: true}, | ||
"POST:/api/v2/organizations/{organization}/templates": {NoAuthorize: true}, | ||
@@ -143,11 +141,21 @@ func TestAuthorizeAllEndpoints(t *testing.T) { | ||
AssertObject: rbac.ResourceWorkspace.InOrg(organization.ID).WithID(workspace.ID.String()).WithOwner(workspace.OwnerID.String()), | ||
}, | ||
"GET:/api/v2/organizations/{organization}/workspaces": {StatusCode: http.StatusOK, AssertObject: rbac.ResourceWorkspace}, | ||
"GET:/api/v2/workspaces": {StatusCode: http.StatusOK, AssertObject: rbac.ResourceWorkspace}, | ||
// These endpoints need payloads to get to the auth part. | ||
"PUT:/api/v2/users/{user}/roles": {StatusCode: http.StatusBadRequest, NoAuthorize: true}, | ||
} | ||
for k, v := range assertRoute { | ||
noTrailSlash := strings.TrimRight(k, "/") | ||
if _, ok := assertRoute[noTrailSlash]; ok && noTrailSlash != k { | ||
t.Errorf("route %q & %q is declared twice", noTrailSlash, k) | ||
t.FailNow() | ||
} | ||
assertRoute[noTrailSlash] = v | ||
} | ||
Comment on lines +150 to +157 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Routes were being duplicated with a trailing slash. Just catching dev errors. | ||
c, _ := srv.Config.Handler.(*chi.Mux) | ||
err = chi.Walk(c, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error { | ||
name := method + ":" + route | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.