(requires *ast.Requires, cache *templater.Cache)
| 487 | } |
| 488 | |
| 489 | func 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. |
| 519 | func product(matrix *ast.Matrix) []map[string]any { |
no test coverage detected
searching dependent graphs…