MCPcopy
hub / github.com/go-task/task / resolveEnumRefs

Function resolveEnumRefs

variables.go:489–516  ·  view source on GitHub ↗
(requires *ast.Requires, cache *templater.Cache)

Source from the content-addressed store, hash-verified

487}
488
489func resolveEnumRefs(requires *ast.Requires, cache *templater.Cache) error {
490 if requires == nil || len(requires.Vars) == 0 {
491 return nil
492 }
493 for _, v := range requires.Vars {
494 if v.Enum == nil || v.Enum.Ref == "" {
495 continue
496 }
497 resolved := templater.ResolveRef(v.Enum.Ref, cache)
498 if cache.Err() != nil {
499 return cache.Err()
500 }
501 arr, ok := resolved.([]any)
502 if !ok {
503 return fmt.Errorf("enum reference %q must resolve to a list", v.Enum.Ref)
504 }
505 strValues := make([]string, 0, len(arr))
506 for _, item := range arr {
507 s, ok := item.(string)
508 if !ok {
509 return fmt.Errorf("enum reference %q must contain only strings", v.Enum.Ref)
510 }
511 strValues = append(strValues, s)
512 }
513 v.Enum.Value = strValues
514 }
515 return nil
516}
517
518// product generates the cartesian product of the input map of slices.
519func product(matrix *ast.Matrix) []map[string]any {

Callers 1

compiledTaskMethod · 0.85

Calls 2

ResolveRefFunction · 0.92
ErrMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…