(ctx context.Context, exitHook *wfv1.LifecycleHook, parentNode *wfv1.NodeStatus, boundaryID string, tmplCtx *templateresolution.TemplateContext, prefix string, scope *wfScope)
| 14 | ) |
| 15 | |
| 16 | func (woc *wfOperationCtx) runOnExitNode(ctx context.Context, exitHook *wfv1.LifecycleHook, parentNode *wfv1.NodeStatus, boundaryID string, tmplCtx *templateresolution.TemplateContext, prefix string, scope *wfScope) (bool, *wfv1.NodeStatus, error) { |
| 17 | outputs := parentNode.Outputs |
| 18 | if lastChildNode := woc.possiblyGetRetryChildNode(parentNode); lastChildNode != nil { |
| 19 | outputs = lastChildNode.Outputs |
| 20 | } |
| 21 | |
| 22 | if exitHook != nil && woc.GetShutdownStrategy().ShouldExecute(true) { |
| 23 | execute := true |
| 24 | var err error |
| 25 | if exitHook.Expression != "" { |
| 26 | execute, err = argoexpr.EvalBool(exitHook.Expression, env.GetFuncMap(template.EnvMap(woc.globalParams.Merge(scope.getParameters())))) |
| 27 | if err != nil { |
| 28 | return true, nil, err |
| 29 | } |
| 30 | } |
| 31 | if execute { |
| 32 | woc.log.WithField("lifeCycleHook", exitHook).Info(ctx, "Running OnExit handler") |
| 33 | onExitNodeName := common.GenerateOnExitNodeName(parentNode.Name) |
| 34 | resolvedArgs := exitHook.Arguments |
| 35 | if !resolvedArgs.IsEmpty() { |
| 36 | resolvedArgs, err = woc.resolveExitTmplArgument(ctx, exitHook.Arguments, prefix, outputs, scope) |
| 37 | if err != nil { |
| 38 | return true, nil, err |
| 39 | } |
| 40 | |
| 41 | } |
| 42 | onExitNode, err := woc.executeTemplate(ctx, onExitNodeName, &wfv1.WorkflowStep{Template: exitHook.Template, TemplateRef: exitHook.TemplateRef}, tmplCtx, resolvedArgs, &executeTemplateOpts{ |
| 43 | boundaryID: boundaryID, |
| 44 | onExitTemplate: true, |
| 45 | nodeFlag: &wfv1.NodeFlag{Hooked: true}, |
| 46 | }) |
| 47 | woc.addChildNode(ctx, parentNode.Name, onExitNodeName) |
| 48 | return true, onExitNode, err |
| 49 | } |
| 50 | } |
| 51 | return false, nil, nil |
| 52 | } |
| 53 | |
| 54 | func (woc *wfOperationCtx) resolveExitTmplArgument(ctx context.Context, args wfv1.Arguments, prefix string, outputs *wfv1.Outputs, scope *wfScope) (wfv1.Arguments, error) { |
| 55 | if scope == nil { |
no test coverage detected