feat(requires): support variable references in enum constraints by vmaerten · Pull Request #2678 · go-task/task
added 6 commits
January 25, 2026 15:17Add support for referencing variables in enum validation:
```yaml
vars:
ALLOWED_ENVS: ["dev", "staging", "prod"]
tasks:
deploy:
requires:
vars:
- name: ENV
enum:
ref: .ALLOWED_ENVS
```
This allows enum values to be defined once and reused, or computed
dynamically using template expressions like `| fromYaml`.
Changes:
- Add Enum type with Ref/Value fields in taskfile/ast/requires.go
- Add resolveEnumRefs() to resolve refs at task compilation time
- Add getEnumValues() helper in requires.go
- Only resolve enum refs when shell variables are evaluated
vmaerten
marked this pull request as ready for review
- Check cache.Err() after ResolveRef to surface template parse errors - Resolve enum refs in all compilation paths (not just evaluateShVars) - Validate non-empty ref in Enum.UnmarshalYAML to reject empty mappings - Display enum ref expression in task summary when values are unresolved - Fix Go template pipeline syntax in docs (use parentheses) - Update JSON schema to accept enum as object with ref key - Add test for enum ref to nonexistent variable
vmaerten
deleted the
feat/enum-ref-support
branch
Copilot AI pushed a commit to libor-m/task that referenced this pull request
Mar 27, 2026…ask#2678) Co-authored-by: libor-m <1497769+libor-m@users.noreply.github.com>
Copilot AI pushed a commit to libor-m/task that referenced this pull request
Mar 27, 2026This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters