Azure supports instance identity verification: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service?tabs=linux#tabgroup_14 @Summary Create workspace build @ID create-workspace-build @Security CoderSessionToken @Accept json @Produce json @Tags Builds @Param works
(rw http.ResponseWriter, r *http.Request)
| 326 | // @Success 200 {object} codersdk.WorkspaceBuild |
| 327 | // @Router /api/v2/workspaces/{workspace}/builds [post] |
| 328 | func (api *API) postWorkspaceBuilds(rw http.ResponseWriter, r *http.Request) { |
| 329 | ctx := r.Context() |
| 330 | apiKey := httpmw.APIKey(r) |
| 331 | workspace := httpmw.WorkspaceParam(r) |
| 332 | var createBuild codersdk.CreateWorkspaceBuildRequest |
| 333 | if !httpapi.Read(ctx, rw, r, &createBuild) { |
| 334 | return |
| 335 | } |
| 336 | |
| 337 | // We want to allow a delete build for a deleted workspace, but not a start or stop build. |
| 338 | if workspace.Deleted && createBuild.Transition != codersdk.WorkspaceTransitionDelete { |
| 339 | httpapi.Write(ctx, rw, http.StatusConflict, codersdk.Response{ |
| 340 | Message: fmt.Sprintf("Cannot %s a deleted workspace!", createBuild.Transition), |
| 341 | Detail: "This workspace has been deleted and cannot be modified.", |
| 342 | }) |
| 343 | return |
| 344 | } |
| 345 | |
| 346 | apiBuild, err := api.postWorkspaceBuildsInternal( |
| 347 | ctx, |
| 348 | apiKey, |
| 349 | workspace, |
| 350 | createBuild, |
| 351 | func(action policy.Action, object rbac.Objecter) bool { |
| 352 | return api.Authorize(r, action, object) |
| 353 | }, |
| 354 | audit.WorkspaceBuildBaggageFromRequest(r), |
| 355 | ) |
| 356 | if err != nil { |
| 357 | httperror.WriteWorkspaceBuildError(ctx, rw, err) |
| 358 | return |
| 359 | } |
| 360 | |
| 361 | httpapi.Write(ctx, rw, http.StatusCreated, apiBuild) |
| 362 | } |
| 363 | |
| 364 | // postWorkspaceBuildsInternal handles the internal logic for creating |
| 365 | // workspace builds, can be called by other handlers and must not |
nothing calls this directly
no test coverage detected