MCPcopy Index your code
hub / github.com/coder/coder / deleteWorkspaceACL

Method deleteWorkspaceACL

coderd/workspaces.go:2589–2631  ·  view source on GitHub ↗

@Summary Completely clears the workspace's user and group ACLs. @ID completely-clears-the-workspaces-user-and-group-acls @Security CoderSessionToken @Tags Workspaces @Param workspace path string true "Workspace ID" format(uuid) @Success 204 @Router /api/v2/workspaces/{workspace}/acl [delete]

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

2587// @Success 204
2588// @Router /api/v2/workspaces/{workspace}/acl [delete]
2589func (api *API) deleteWorkspaceACL(rw http.ResponseWriter, r *http.Request) {
2590 var (
2591 ctx = r.Context()
2592 workspace = httpmw.WorkspaceParam(r)
2593 auditor = api.Auditor.Load()
2594 aReq, commitAuditor = audit.InitRequest[database.WorkspaceTable](rw, &audit.RequestParams{
2595 Audit: *auditor,
2596 Log: api.Logger,
2597 Request: r,
2598 Action: database.AuditActionWrite,
2599 OrganizationID: workspace.OrganizationID,
2600 })
2601 )
2602
2603 defer commitAuditor()
2604 aReq.Old = workspace.WorkspaceTable()
2605
2606 if !api.allowWorkspaceSharing(ctx, rw, workspace.OrganizationID) {
2607 return
2608 }
2609
2610 err := api.Database.InTx(func(tx database.Store) error {
2611 err := tx.DeleteWorkspaceACLByID(ctx, workspace.ID)
2612 if err != nil {
2613 return xerrors.Errorf("delete workspace by ID: %w", err)
2614 }
2615
2616 workspace, err = tx.GetWorkspaceByID(ctx, workspace.ID)
2617 if err != nil {
2618 return xerrors.Errorf("get updated workspace by ID: %w", err)
2619 }
2620
2621 return nil
2622 }, nil)
2623 if err != nil {
2624 httpapi.InternalServerError(rw, err)
2625 return
2626 }
2627
2628 aReq.New = workspace.WorkspaceTable()
2629
2630 httpapi.Write(ctx, rw, http.StatusNoContent, nil)
2631}
2632
2633// allowWorkspaceSharing enforces the workspace-sharing gate for an
2634// organization. It writes an HTTP error response and returns false if

Callers

nothing calls this directly

Calls 12

allowWorkspaceSharingMethod · 0.95
WorkspaceParamFunction · 0.92
InitRequestFunction · 0.92
InternalServerErrorFunction · 0.92
WriteFunction · 0.92
WorkspaceTableMethod · 0.80
ContextMethod · 0.65
InTxMethod · 0.65
GetWorkspaceByIDMethod · 0.65
LoadMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected