Skip to content

Commit 3a8c2b6

Browse files
committed
[core] Ensure task class defaults are template-processed
1 parent fb6789b commit 3a8c2b6

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

core/task/task.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,22 @@ func (t *Task) BuildTaskCommand(role parentRole) (err error) {
261261
return
262262
}
263263

264-
// We wrap the parent varStack around the class Defaults, ensuring
265-
// the class Defaults are overridden by anything else.
266-
varStack, err = gera.MakeStringMapWithMap(varStack).WrappedAndFlattened(class.Defaults)
264+
// We make a copy of the Defaults map from the taskClass, this is necessary because
265+
// entries may be templated, so they may resolve to different values in each task.
266+
localDefaults := class.Defaults.Copy().Raw()
267+
268+
// We resolve any template expressions in Defaults
269+
defaultFields := template.WrapMapItems(localDefaults)
270+
271+
err = defaultFields.Execute(the.ConfSvc(), t.name, varStack, nil, make(map[string]texttemplate.Template))
272+
if err != nil {
273+
t.commandInfo = &common.TaskCommandInfo{}
274+
log.WithError(err).Error("cannot resolve templates for task defaults")
275+
}
276+
277+
// We wrap the parent varStack around the task's already processed Defaults,
278+
// ensuring that any taskclass Defaults are overridden by anything else.
279+
varStack, err = gera.MakeStringMapWithMap(varStack).WrappedAndFlattened(gera.MakeStringMapWithMap(localDefaults))
267280
if err != nil {
268281
log.WithError(err).Error("cannot fetch task class defaults for task command info")
269282
return

0 commit comments

Comments
 (0)