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

Method InsertWorkspace

coderd/database/dbauthz/dbauthz.go:5907–5918  ·  view source on GitHub ↗
(ctx context.Context, arg database.InsertWorkspaceParams)

Source from the content-addressed store, hash-verified

5905}
5906
5907func (q *querier) InsertWorkspace(ctx context.Context, arg database.InsertWorkspaceParams) (database.WorkspaceTable, error) {
5908 obj := rbac.ResourceWorkspace.WithOwner(arg.OwnerID.String()).InOrg(arg.OrganizationID)
5909 tpl, err := q.GetTemplateByID(ctx, arg.TemplateID)
5910 if err != nil {
5911 return database.WorkspaceTable{}, xerrors.Errorf("verify template by id: %w", err)
5912 }
5913 if err := q.authorizeContext(ctx, policy.ActionUse, tpl); err != nil {
5914 return database.WorkspaceTable{}, xerrors.Errorf("use template for workspace: %w", err)
5915 }
5916
5917 return insert(q.log, q.auth, obj, q.db.InsertWorkspace)(ctx, arg)
5918}
5919
5920func (q *querier) InsertWorkspaceAgent(ctx context.Context, arg database.InsertWorkspaceAgentParams) (database.WorkspaceAgent, error) {
5921 // NOTE(DanielleMaywood):

Callers

nothing calls this directly

Calls 7

GetTemplateByIDMethod · 0.95
authorizeContextMethod · 0.95
insertFunction · 0.85
InOrgMethod · 0.80
WithOwnerMethod · 0.80
StringMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected