@@ -26,6 +26,7 @@ package workflow
2626
2727import (
2828 "errors"
29+ "strings"
2930 texttemplate "text/template"
3031
3132 "github.com/AliceO2Group/Control/core/repos"
@@ -91,9 +92,10 @@ func (r *aggregatorRole) ProcessTemplates(workflowRepo *repos.Repo) (err error)
9192 template .STAGE3 : template.Fields {
9293 template .WrapPointer (& r .Name ),
9394 },
94- template .STAGE4 : append (
95+ template .STAGE4 : append (append (
9596 template .WrapConstraints (r .Constraints ),
9697 r .wrapConnectFields ()... ),
98+ template .WrapPointer (& r .Enabled )),
9799 }
98100
99101 // TODO: push cached templates here
@@ -116,13 +118,27 @@ func (r *aggregatorRole) ProcessTemplates(workflowRepo *repos.Repo) (err error)
116118 r .Vars .Set (k , v )
117119 }
118120
121+ r .Enabled = strings .TrimSpace (r .Enabled )
122+
123+ // Process templates for child roles
119124 for _ , role := range r .Roles {
120125 role .setParent (r )
121126 err = role .ProcessTemplates (workflowRepo )
122127 if err != nil {
123128 return
124129 }
125130 }
131+
132+ // If any child is not Enabled after template resolution,
133+ // we filter it out of existence
134+ enabledRoles := make ([]Role , 0 )
135+ for _ , role := range r .Roles {
136+ if role .IsEnabled () {
137+ enabledRoles = append (enabledRoles , role )
138+ }
139+ }
140+ r .Roles = enabledRoles
141+
126142 return
127143}
128144
0 commit comments