Skip to content

Commit

Permalink
refactor: invert conditionals for less nesting in `includeScriptOutpu…
Browse files Browse the repository at this point in the history
…t` (#12146)

Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
  • Loading branch information
Anton Gilgur authored Dec 6, 2023
1 parent 8859c92 commit 64ee6ae
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3739,29 +3739,30 @@ func (woc *wfOperationCtx) deletePDBResource(ctx context.Context) error {
// Check if the output of this node is referenced elsewhere in the Workflow. If so, make sure to include it during
// execution.
func (woc *wfOperationCtx) includeScriptOutput(nodeName, boundaryID string) (bool, error) {
if boundaryID != "" {
if boundaryNode, err := woc.wf.Status.Nodes.Get(boundaryID); err == nil {
tmplCtx, err := woc.createTemplateContext(boundaryNode.GetTemplateScope())
if err != nil {
return false, err
}
_, parentTemplate, templateStored, err := tmplCtx.ResolveTemplate(boundaryNode)
if err != nil {
return false, err
}
// A new template was stored during resolution, persist it
if templateStored {
woc.updated = true
}
if boundaryID == "" {
return false, nil
}
boundaryNode, err := woc.wf.Status.Nodes.Get(boundaryID)
if err != nil {
woc.log.Errorf("was unable to obtain node for %s", boundaryID)
return false, err
}

name := getStepOrDAGTaskName(nodeName)
return hasOutputResultRef(name, parentTemplate), nil
} else {
woc.log.Errorf("was unable to obtain node for %s", boundaryID)
}
tmplCtx, err := woc.createTemplateContext(boundaryNode.GetTemplateScope())
if err != nil {
return false, err
}
_, parentTemplate, templateStored, err := tmplCtx.ResolveTemplate(boundaryNode)
if err != nil {
return false, err
}
// A new template was stored during resolution, persist it
if templateStored {
woc.updated = true
}

return false, nil
name := getStepOrDAGTaskName(nodeName)
return hasOutputResultRef(name, parentTemplate), nil
}

func (woc *wfOperationCtx) fetchWorkflowSpec() (wfv1.WorkflowSpecHolder, error) {
Expand Down

0 comments on commit 64ee6ae

Please sign in to comment.