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

Function waitForVersion

scripts/develop/main.go:1075–1093  ·  view source on GitHub ↗

waitForVersion polls until a template version's provisioner job reaches a terminal state.

(ctx context.Context, client *codersdk.Client, id uuid.UUID)

Source from the content-addressed store, hash-verified

1073// waitForVersion polls until a template version's provisioner job
1074// reaches a terminal state.
1075func waitForVersion(ctx context.Context, client *codersdk.Client, id uuid.UUID) (codersdk.TemplateVersion, error) {
1076 return poll(ctx, 500*time.Millisecond,
1077 func(ctx context.Context) (codersdk.TemplateVersion, bool, error) {
1078 v, err := client.TemplateVersion(ctx, id)
1079 if err != nil {
1080 return v, false, err
1081 }
1082 switch v.Job.Status {
1083 case codersdk.ProvisionerJobSucceeded:
1084 return v, true, nil
1085 case codersdk.ProvisionerJobFailed:
1086 return v, false, xerrors.Errorf("job failed: %s", v.Job.Error)
1087 case codersdk.ProvisionerJobCanceled:
1088 return v, false, xerrors.New("job was canceled")
1089 default:
1090 return v, false, nil // Still pending/running.
1091 }
1092 })
1093}
1094
1095// createTemplateInOrg ensures a starter template exists in the
1096// given org, creating it from the example if needed.

Callers 1

createTemplateInOrgFunction · 0.85

Calls 4

pollFunction · 0.85
TemplateVersionMethod · 0.65
NewMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected