Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: invert conditionals for less nesting in includeScriptOutput #12146

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 21 additions & 20 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3688,29 +3688,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
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would've returned false, nil before

}

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