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

Method templateVersionDryRunMatchedProvisioners

coderd/templateversions.go:614–640  ·  view source on GitHub ↗

@Summary Get template version dry-run matched provisioners @ID get-template-version-dry-run-matched-provisioners @Security CoderSessionToken @Produce json @Tags Templates @Param templateversion path string true "Template version ID" format(uuid) @Param jobID path string true "Job ID" format(uuid) @S

(rw http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

612// @Success 200 {object} codersdk.MatchedProvisioners
613// @Router /api/v2/templateversions/{templateversion}/dry-run/{jobID}/matched-provisioners [get]
614func (api *API) templateVersionDryRunMatchedProvisioners(rw http.ResponseWriter, r *http.Request) {
615 ctx := r.Context()
616 job, ok := api.fetchTemplateVersionDryRunJob(rw, r)
617 if !ok {
618 return
619 }
620
621 // nolint:gocritic // The user may not have permissions to read all
622 // provisioner daemons in the org.
623 daemons, err := api.Database.GetProvisionerDaemonsByOrganization(dbauthz.AsSystemReadProvisionerDaemons(ctx), database.GetProvisionerDaemonsByOrganizationParams{
624 OrganizationID: job.ProvisionerJob.OrganizationID,
625 WantTags: job.ProvisionerJob.Tags,
626 })
627 if err != nil {
628 if !errors.Is(err, sql.ErrNoRows) {
629 httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
630 Message: "Internal error fetching provisioner daemons by organization.",
631 Detail: err.Error(),
632 })
633 return
634 }
635 daemons = []database.ProvisionerDaemon{}
636 }
637
638 matchedProvisioners := db2sdk.MatchedProvisioners(daemons, dbtime.Now(), provisionerdserver.StaleInterval)
639 httpapi.Write(ctx, rw, http.StatusOK, matchedProvisioners)
640}
641
642// @Summary Get template version dry-run resources by job ID
643// @ID get-template-version-dry-run-resources-by-job-id

Callers

nothing calls this directly

Calls 9

WriteFunction · 0.92
MatchedProvisionersFunction · 0.92
NowFunction · 0.92
ContextMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected