MCPcopy
hub / github.com/argoproj/argo-workflows / newWorkflowOperationCtx

Function newWorkflowOperationCtx

workflow/controller/operator.go:151–186  ·  view source on GitHub ↗

newWorkflowOperationCtx creates and initializes a new wfOperationCtx object.

(ctx context.Context, wf *wfv1.Workflow, wfc *WorkflowController)

Source from the content-addressed store, hash-verified

149
150// newWorkflowOperationCtx creates and initializes a new wfOperationCtx object.
151func newWorkflowOperationCtx(ctx context.Context, wf *wfv1.Workflow, wfc *WorkflowController) *wfOperationCtx {
152 // NEVER modify objects from the store. It's a read-only, local cache.
153 // You can use DeepCopy() to make a deep copy of original object and modify this copy
154 // Or create a copy manually for better performance
155 wfCopy := wf.DeepCopyObject().(*wfv1.Workflow)
156
157 slogger := logging.RequireLoggerFromContext(ctx)
158
159 woc := wfOperationCtx{
160 wf: wfCopy,
161 orig: wf,
162 execWf: wfCopy,
163 updated: false,
164 log: slogger.WithFields(logging.Fields{
165 "workflow": wf.Name,
166 "namespace": wf.Namespace,
167 }),
168 controller: wfc,
169 globalParams: make(map[string]string),
170 volumes: wf.Spec.DeepCopy().Volumes,
171 deadline: time.Now().UTC().Add(maxOperationTime),
172 eventRecorder: wfc.eventRecorderManager.Get(ctx, wf.Namespace),
173 preExecutionNodeStatuses: make(map[string]wfv1.NodeStatus),
174 taskSet: make(map[string]wfv1.Template),
175 currentStackDepth: 0,
176 }
177
178 if woc.wf.Status.Nodes == nil {
179 woc.wf.Status.Nodes = make(map[string]wfv1.NodeStatus)
180 }
181
182 if woc.wf.Status.StoredTemplates == nil {
183 woc.wf.Status.StoredTemplates = make(map[string]wfv1.Template)
184 }
185 return &woc
186}
187
188// operate is the main operator logic of a workflow. It evaluates the current state of the workflow,
189// and its pods and decides how to proceed down the execution path.

Calls 6

RequireLoggerFromContextFunction · 0.92
WithFieldsMethod · 0.65
AddMethod · 0.65
GetMethod · 0.65
DeepCopyObjectMethod · 0.45
DeepCopyMethod · 0.45