(ctx context.Context, arg database.InsertWorkspaceAgentParams)
| 5918 | } |
| 5919 | |
| 5920 | func (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 | |
| 5942 | func (q *querier) InsertWorkspaceAgentDevcontainers(ctx context.Context, arg database.InsertWorkspaceAgentDevcontainersParams) ([]database.WorkspaceAgentDevcontainer, error) { |
| 5943 | if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceWorkspaceAgentDevcontainers); err != nil { |
nothing calls this directly
no test coverage detected