From 7ee13e2cc98329465688907fb68954489b7772f6 Mon Sep 17 00:00:00 2001 From: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:30:07 +1100 Subject: [PATCH] Signed-off-by: tooptoop4 <33283496+tooptoop4@users.noreply.github.com> --- workflow/controller/operator.go | 50 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/workflow/controller/operator.go b/workflow/controller/operator.go index 16ddf218a2c8..87527cd5ef9d 100644 --- a/workflow/controller/operator.go +++ b/workflow/controller/operator.go @@ -3089,34 +3089,36 @@ func (woc *wfOperationCtx) buildLocalScope(scope *wfScope, prefix string, node * node = lastChildNode } - if node.ID != "" { - key := fmt.Sprintf("%s.id", prefix) - scope.addParamToScope(key, node.ID) - } + if node != nil { + if node.ID != "" { + key := fmt.Sprintf("%s.id", prefix) + scope.addParamToScope(key, node.ID) + } - if !node.StartedAt.Time.IsZero() { - key := fmt.Sprintf("%s.startedAt", prefix) - scope.addParamToScope(key, node.StartedAt.Time.Format(time.RFC3339)) - } + if !node.StartedAt.Time.IsZero() { + key := fmt.Sprintf("%s.startedAt", prefix) + scope.addParamToScope(key, node.StartedAt.Time.Format(time.RFC3339)) + } - if !node.FinishedAt.Time.IsZero() { - key := fmt.Sprintf("%s.finishedAt", prefix) - scope.addParamToScope(key, node.FinishedAt.Time.Format(time.RFC3339)) - } + if !node.FinishedAt.Time.IsZero() { + key := fmt.Sprintf("%s.finishedAt", prefix) + scope.addParamToScope(key, node.FinishedAt.Time.Format(time.RFC3339)) + } - if node.PodIP != "" { - key := fmt.Sprintf("%s.ip", prefix) - scope.addParamToScope(key, node.PodIP) - } - if node.Phase != "" { - key := fmt.Sprintf("%s.status", prefix) - scope.addParamToScope(key, string(node.Phase)) - } - if node.HostNodeName != "" { - key := fmt.Sprintf("%s.hostNodeName", prefix) - scope.addParamToScope(key, string(node.HostNodeName)) + if node.PodIP != "" { + key := fmt.Sprintf("%s.ip", prefix) + scope.addParamToScope(key, node.PodIP) + } + if node.Phase != "" { + key := fmt.Sprintf("%s.status", prefix) + scope.addParamToScope(key, string(node.Phase)) + } + if node.HostNodeName != "" { + key := fmt.Sprintf("%s.hostNodeName", prefix) + scope.addParamToScope(key, string(node.HostNodeName)) + } + woc.addOutputsToLocalScope(prefix, node.Outputs, scope) } - woc.addOutputsToLocalScope(prefix, node.Outputs, scope) } func (woc *wfOperationCtx) addOutputsToLocalScope(prefix string, outputs *wfv1.Outputs, scope *wfScope) {