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

Method checkTemplateJobStatus

coderd/wsbuilder/wsbuilder.go:1353–1392  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1351}
1352
1353func (b *Builder) checkTemplateJobStatus() error {
1354 templateVersion, err := b.getTemplateVersion()
1355 if err != nil {
1356 return BuildError{http.StatusInternalServerError, "failed to fetch template version", err}
1357 }
1358
1359 templateVersionJob, err := b.getTemplateVersionJob()
1360 if err != nil {
1361 return BuildError{
1362 http.StatusInternalServerError, "failed to fetch template version job", err,
1363 }
1364 }
1365
1366 templateVersionJobStatus := codersdk.ProvisionerJobStatus(templateVersionJob.JobStatus)
1367 switch templateVersionJobStatus {
1368 case codersdk.ProvisionerJobPending, codersdk.ProvisionerJobRunning:
1369 msg := fmt.Sprintf("The provided template version is %s. Wait for it to complete importing!", templateVersionJobStatus)
1370
1371 return BuildError{
1372 http.StatusNotAcceptable,
1373 msg,
1374 xerrors.New(msg),
1375 }
1376 case codersdk.ProvisionerJobFailed:
1377 msg := fmt.Sprintf("The provided template version %q has failed to import: %q. You cannot build workspaces with it!", templateVersion.Name, templateVersionJob.Error.String)
1378 return BuildError{
1379 http.StatusBadRequest,
1380 msg,
1381 xerrors.New(msg),
1382 }
1383 case codersdk.ProvisionerJobCanceled:
1384 msg := fmt.Sprintf("The provided template version %q has failed to import: %q. You cannot build workspaces with it!", templateVersion.Name, templateVersionJob.Error.String)
1385 return BuildError{
1386 http.StatusBadRequest,
1387 msg,
1388 xerrors.New(msg),
1389 }
1390 }
1391 return nil
1392}
1393
1394func (b *Builder) checkUsage() error {
1395 templateVersion, err := b.getTemplateVersion()

Callers 1

buildTxMethod · 0.95

Calls 4

getTemplateVersionMethod · 0.95
getTemplateVersionJobMethod · 0.95
ProvisionerJobStatusTypeAlias · 0.92
NewMethod · 0.65

Tested by

no test coverage detected