@Summary Get template variables by template version @ID get-template-variables-by-template-version @Security CoderSessionToken @Produce json @Tags Templates @Param templateversion path string true "Template version ID" format(uuid) @Success 200 {array} codersdk.TemplateVersionVariable @Router /api/v
(rw http.ResponseWriter, r *http.Request)
| 436 | // @Success 200 {array} codersdk.TemplateVersionVariable |
| 437 | // @Router /api/v2/templateversions/{templateversion}/variables [get] |
| 438 | func (api *API) templateVersionVariables(rw http.ResponseWriter, r *http.Request) { |
| 439 | ctx := r.Context() |
| 440 | templateVersion := httpmw.TemplateVersionParam(r) |
| 441 | |
| 442 | job, err := api.Database.GetProvisionerJobByID(ctx, templateVersion.JobID) |
| 443 | if err != nil { |
| 444 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 445 | Message: "Internal error fetching provisioner job.", |
| 446 | Detail: err.Error(), |
| 447 | }) |
| 448 | return |
| 449 | } |
| 450 | if !job.CompletedAt.Valid { |
| 451 | httpapi.Write(ctx, rw, http.StatusForbidden, codersdk.Response{ |
| 452 | Message: "Template version job has not finished", |
| 453 | }) |
| 454 | return |
| 455 | } |
| 456 | dbTemplateVersionVariables, err := api.Database.GetTemplateVersionVariables(ctx, templateVersion.ID) |
| 457 | if err != nil { |
| 458 | httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{ |
| 459 | Message: "Internal error fetching template version variables.", |
| 460 | Detail: err.Error(), |
| 461 | }) |
| 462 | return |
| 463 | } |
| 464 | |
| 465 | httpapi.Write(ctx, rw, http.StatusOK, convertTemplateVersionVariables(dbTemplateVersionVariables)) |
| 466 | } |
| 467 | |
| 468 | // @Summary Create template version dry-run |
| 469 | // @ID create-template-version-dry-run |
nothing calls this directly
no test coverage detected