3
0

Fixes Wf duplicate issues for gateway steps

Prevents gateway steps from verifying again by fixing return logic for converting those step definitions into workflow.Step instances
This commit is contained in:
Vivek Patel 2021-10-06 20:03:48 +05:30
parent fd07179be2
commit d4bf6fc6bb
2 changed files with 14 additions and 11 deletions

View File

@ -203,16 +203,16 @@ func (svc workflowConverter) workflowStepDefConv(g *wfexec.Graph, s *types.Workf
}
}()
if err != nil {
return false, err
} else if conv != nil {
conv.SetID(s.ID)
g.AddStep(conv)
return true, err
} else {
if err == nil && conv == nil {
// signal caller that we were unable to
// resolve definition at the moment
return false, nil
} else {
if conv != nil {
conv.SetID(s.ID)
g.AddStep(conv)
}
return err == nil, err
}
}
@ -276,6 +276,9 @@ func (svc workflowConverter) convGateway(g *wfexec.Graph, s *types.WorkflowStep,
}
}
// return empty struct even if we get an error,
// so step definitions converted into workflow.Step instances
// and this step don't go through verification more than one time
if s.Ref == "excl" {
return wfexec.ExclGateway(pp...)
} else {

View File

@ -100,12 +100,12 @@ type inclGateway struct {
// InclGateway fn initializes inclusive gateway
func InclGateway(pp ...*GatewayPath) (*inclGateway, error) {
if len(pp) < 2 {
return nil, fmt.Errorf("expecting at least two paths for incusive gateway")
return &inclGateway{}, fmt.Errorf("expecting at least two paths for incusive gateway")
}
for _, p := range pp {
if p.test == nil {
return nil, fmt.Errorf("all inclusve gateway paths must have valid test Expression")
return &inclGateway{}, fmt.Errorf("all inclusve gateway paths must have valid test Expression")
}
}
@ -142,12 +142,12 @@ type exclGateway struct {
func ExclGateway(pp ...*GatewayPath) (*exclGateway, error) {
t := len(pp)
if t < 2 {
return nil, fmt.Errorf("expecting at least two paths for exclusive gateway")
return &exclGateway{}, fmt.Errorf("expecting at least two paths for exclusive gateway")
}
for i, p := range pp {
if p.test == nil && i != t-1 {
return nil, fmt.Errorf("all exclusive gateway paths must have valid test Expression")
return &exclGateway{}, fmt.Errorf("all exclusive gateway paths must have valid test Expression")
}
}