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

Function WarnMatchedProvisioners

cli/cliutil/provisionerwarn.go:30–53  ·  view source on GitHub ↗

WarnMatchedProvisioners warns the user if there are no provisioners that match the requested tags for a given provisioner job. If the job is not pending, it is ignored.

(w io.Writer, mp *codersdk.MatchedProvisioners, job codersdk.ProvisionerJob)

Source from the content-addressed store, hash-verified

28// match the requested tags for a given provisioner job.
29// If the job is not pending, it is ignored.
30func WarnMatchedProvisioners(w io.Writer, mp *codersdk.MatchedProvisioners, job codersdk.ProvisionerJob) {
31 if mp == nil {
32 // Nothing in the response, nothing to do here!
33 return
34 }
35 if job.Status != codersdk.ProvisionerJobPending {
36 // Only warn if the job is pending.
37 return
38 }
39 var tagsJSON strings.Builder
40 if err := json.NewEncoder(&tagsJSON).Encode(job.Tags); err != nil {
41 // Fall back to the less-pretty string representation.
42 tagsJSON.Reset()
43 _, _ = tagsJSON.WriteString(fmt.Sprintf("%v", job.Tags))
44 }
45 if mp.Count == 0 {
46 cliui.Warnf(w, warnNoMatchedProvisioners, job.ID, tagsJSON.String())
47 return
48 }
49 if mp.Available == 0 {
50 cliui.Warnf(w, warnNoAvailableProvisioners, job.ID, strings.TrimSpace(tagsJSON.String()), mp.MostRecentlySeen.Time)
51 return
52 }
53}

Callers 8

stopWorkspaceFunction · 0.92
startMethod · 0.92
startWorkspaceFunction · 0.92
deleteWorkspaceMethod · 0.92
CreateMethod · 0.92
prepWorkspaceBuildFunction · 0.92

Calls 5

WarnfFunction · 0.92
EncodeMethod · 0.80
WriteStringMethod · 0.80
ResetMethod · 0.65
StringMethod · 0.45

Tested by 1