2525package workflow
2626
2727import (
28- "github.com/AliceO2Group/Control/core/task/channel"
29- "github.com/AliceO2Group/Control/common/logger"
30- "github.com/sirupsen/logrus"
31- "github.com/jinzhu/copier"
3228 "bytes"
3329 "fmt"
3430 "text/template"
3531
32+ "github.com/AliceO2Group/Control/common/logger"
33+ "github.com/AliceO2Group/Control/core/task/channel"
34+ "github.com/jinzhu/copier"
35+ "github.com/sirupsen/logrus"
36+
3637 "github.com/AliceO2Group/Control/core/task"
37- "github.com/pborman/uuid"
3838 "github.com/AliceO2Group/Control/core/task/constraint"
39+ "github.com/pborman/uuid"
3940)
4041
4142var log = logger .New (logrus .StandardLogger (), "workflow" )
@@ -79,8 +80,6 @@ func (r *roleBase) UnmarshalYAML(unmarshal func(interface{}) error) (err error)
7980 if err == nil {
8081 * r = roleBase (role )
8182 }
82-
83- r .resolveOutboundChannelTargets ()
8483 return
8584}
8685
@@ -102,9 +101,12 @@ func (r *roleBase) resolveOutboundChannelTargets() {
102101 }
103102 return p .GetPath ()
104103 },
105- "up" : func (levels uint ) string {
104+ "up" : func (levels int ) string {
105+ if levels <= 0 {
106+ return r .GetPath ()
107+ }
106108 var p _parentRole = r
107- for i := levels - 1 ; i >= 0 ; i -- {
109+ for i := 0 ; i < levels ; i ++ {
108110 p = p .GetParentRole ()
109111 if p == nil {
110112 log .WithFields (logrus.Fields {"error" : "role has no ancestor" , "role" : r .GetPath ()}).Error ("workflow configuration error" )
@@ -115,7 +117,7 @@ func (r *roleBase) resolveOutboundChannelTargets() {
115117 },
116118 }
117119
118- for _ , ch := range r .Connect {
120+ for i , ch := range r .Connect {
119121 tmpl := template .New (r .GetPath ())
120122 parsed , err := tmpl .Funcs (funcMap ).Parse (ch .Target )
121123 if err != nil {
@@ -129,7 +131,7 @@ func (r *roleBase) resolveOutboundChannelTargets() {
129131 continue
130132 }
131133 // Finally we write the result back to the target string
132- ch .Target = buf .String ()
134+ r . Connect [ i ] .Target = buf .String ()
133135 }
134136}
135137
0 commit comments