feat(cli): variable expansion, scalar bool/int support, precedence fix
- Add $VAR / ${VAR} expansion in effective context (ctx.ExpandVars):
iterates up to 10 passes to resolve transitive chains; circular
references are left as-is after the limit.
- Handle non-string YAML scalars (bool, int, float64) in
ExtractStringVars and varValueString via new ScalarString helper;
values like BUILD: true no longer render as "(complex)" or get
silently dropped from the effective context.
- Variable precedence (GitLab spec): pipeline defaults < workflow-rule
vars < CLI --var flags; implemented correctly in enrichContext;
expansion applied after all sources are merged.
- Update README, CHANGELOG, ROADMAP for v0.2.13.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-8
@@ -404,14 +404,8 @@ func printVarMap(m map[string]any) {
|
||||
}
|
||||
|
||||
func varValueString(v any) string {
|
||||
switch val := v.(type) {
|
||||
case string:
|
||||
return val
|
||||
case map[string]any:
|
||||
if s, ok := val["value"].(string); ok {
|
||||
return s
|
||||
}
|
||||
return "(complex)"
|
||||
if s, ok := cicontext.ScalarString(v); ok {
|
||||
return s
|
||||
}
|
||||
return "(complex)"
|
||||
}
|
||||
@@ -432,6 +426,9 @@ func enrichContext(ctx *cicontext.Context, p *model.Pipeline) {
|
||||
for k, v := range ruleVars {
|
||||
ctx.Inject(k, v)
|
||||
}
|
||||
// Expand $VAR / ${VAR} references within variable values now that all
|
||||
// sources (pipeline, workflow rules, CLI) have been merged.
|
||||
ctx.ExpandVars()
|
||||
}
|
||||
|
||||
func printContext(p *model.Pipeline, ctx *cicontext.Context) {
|
||||
|
||||
Reference in New Issue
Block a user