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

Function fetchTemplate

codersdk/toolsdk/chatgpt.go:351–370  ·  view source on GitHub ↗
(ctx context.Context, deps Deps, templateID string)

Source from the content-addressed store, hash-verified

349}
350
351func fetchTemplate(ctx context.Context, deps Deps, templateID string) (FetchResult, error) {
352 parsedID, err := uuid.Parse(templateID)
353 if err != nil {
354 return FetchResult{}, xerrors.Errorf("invalid template ID, must be a valid UUID: %w", err)
355 }
356 template, err := deps.coderClient.Template(ctx, parsedID)
357 if err != nil {
358 return FetchResult{}, err
359 }
360 templateJSON, err := json.Marshal(template)
361 if err != nil {
362 return FetchResult{}, xerrors.Errorf("failed to marshal template: %w", err)
363 }
364 return FetchResult{
365 ID: template.ID.String(),
366 Title: template.DisplayName,
367 Text: string(templateJSON),
368 URL: fmt.Sprintf("%s/templates/%s/%s", deps.ServerURL(), template.OrganizationName, template.Name),
369 }, nil
370}
371
372type FetchArgs struct {
373 ID string `json:"id"`

Callers 1

chatgpt.goFile · 0.70

Calls 6

TemplateMethod · 0.80
ServerURLMethod · 0.80
ParseMethod · 0.65
ErrorfMethod · 0.45
MarshalMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected