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

Function parseTemplate

cli/exp_scaletest.go:2304–2332  ·  view source on GitHub ↗
(ctx context.Context, client *codersdk.Client, organizationIDs []uuid.UUID, template string)

Source from the content-addressed store, hash-verified

2302}
2303
2304func parseTemplate(ctx context.Context, client *codersdk.Client, organizationIDs []uuid.UUID, template string) (tpl codersdk.Template, err error) {
2305 if id, err := uuid.Parse(template); err == nil && id != uuid.Nil {
2306 tpl, err = client.Template(ctx, id)
2307 if err != nil {
2308 return tpl, xerrors.Errorf("get template by ID %q: %w", template, err)
2309 }
2310 } else {
2311 // List templates in all orgs until we find a match.
2312 orgLoop:
2313 for _, orgID := range organizationIDs {
2314 tpls, err := client.TemplatesByOrganization(ctx, orgID)
2315 if err != nil {
2316 return tpl, xerrors.Errorf("list templates in org %q: %w", orgID, err)
2317 }
2318
2319 for _, t := range tpls {
2320 if t.Name == template {
2321 tpl = t
2322 break orgLoop
2323 }
2324 }
2325 }
2326 }
2327 if tpl.ID == uuid.Nil {
2328 return tpl, xerrors.Errorf("could not find template %q in any organization", template)
2329 }
2330
2331 return tpl, nil
2332}
2333
2334func parseTargetRange(name, targets string) (start, end int, err error) {
2335 if targets == "" {

Callers 6

scaletestTaskStatusMethod · 0.85
getTargetedWorkspacesMethod · 0.85
scaletestCleanupMethod · 0.85
scaletestAutostartMethod · 0.85

Calls 4

TemplateMethod · 0.80
ParseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected