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

Method InsertWorkspaceAgent

coderd/database/dbauthz/dbauthz.go:5920–5940  ·  view source on GitHub ↗
(ctx context.Context, arg database.InsertWorkspaceAgentParams)

Source from the content-addressed store, hash-verified

5918}
5919
5920func (q *querier) InsertWorkspaceAgent(ctx context.Context, arg database.InsertWorkspaceAgentParams) (database.WorkspaceAgent, error) {
5921 // NOTE(DanielleMaywood):
5922 // Currently, the only way to link a Resource back to a Workspace is by following this chain:
5923 //
5924 // WorkspaceResource -> WorkspaceBuild -> Workspace
5925 //
5926 // It is possible for this function to be called without there existing
5927 // a `WorkspaceBuild` to link back to. This means that we want to allow
5928 // execution to continue if there isn't a workspace found to allow this
5929 // behavior to continue.
5930 workspace, err := q.db.GetWorkspaceByResourceID(ctx, arg.ResourceID)
5931 if err != nil && !errors.Is(err, sql.ErrNoRows) {
5932 return database.WorkspaceAgent{}, err
5933 }
5934
5935 if err := q.authorizeContext(ctx, policy.ActionCreateAgent, workspace); err != nil {
5936 return database.WorkspaceAgent{}, err
5937 }
5938
5939 return q.db.InsertWorkspaceAgent(ctx, arg)
5940}
5941
5942func (q *querier) InsertWorkspaceAgentDevcontainers(ctx context.Context, arg database.InsertWorkspaceAgentDevcontainersParams) ([]database.WorkspaceAgentDevcontainer, error) {
5943 if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceWorkspaceAgentDevcontainers); err != nil {

Callers

nothing calls this directly

Calls 4

authorizeContextMethod · 0.95
InsertWorkspaceAgentMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected