From 7cb26db8ed7003b543f7edf2bcd0f83358e37fa9 Mon Sep 17 00:00:00 2001 From: Matt Leader Date: Wed, 1 Nov 2023 17:28:43 -0400 Subject: [PATCH] unfactor Name back to ID --- internal/step/dummy/provider_test.go | 6 +++--- internal/step/foreach/provider.go | 2 +- internal/step/lifecycle.go | 2 +- internal/step/plugin/provider.go | 2 +- internal/step/plugin/provider_test.go | 16 ++++++++-------- workflow/executor.go | 2 +- workflow/model.go | 8 ++++---- workflow/workflow.go | 20 ++++++++++---------- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/internal/step/dummy/provider_test.go b/internal/step/dummy/provider_test.go index 93625ecc..622896e4 100644 --- a/internal/step/dummy/provider_test.go +++ b/internal/step/dummy/provider_test.go @@ -29,13 +29,13 @@ func (s *stageChangeHandler) OnStepComplete( panic(fmt.Errorf("invalid previous stage: %s", previousStage)) } if previousStageOutputID == nil { - panic(fmt.Errorf("no previous stage output Name")) + panic(fmt.Errorf("no previous stage output ID")) } if *previousStageOutputID != "success" { - panic(fmt.Errorf("invalid previous stage output Name: %s", *previousStageOutputID)) + panic(fmt.Errorf("invalid previous stage output ID: %s", *previousStageOutputID)) } if previousStageOutput == nil { - panic(fmt.Errorf("no previous stage output Name")) + panic(fmt.Errorf("no previous stage output ID")) } message := (*previousStageOutput).(map[string]any)["message"].(string) s.message <- message diff --git a/internal/step/foreach/provider.go b/internal/step/foreach/provider.go index a5e63c24..55d3b58b 100644 --- a/internal/step/foreach/provider.go +++ b/internal/step/foreach/provider.go @@ -471,7 +471,7 @@ func (r *runningStep) run() { } r.logger.Debugf("Executing item %d...", i) - // Ignore the output Name here because it can only be "success" + // Ignore the output ID here because it can only be "success" _, outputData, err := r.workflow.Execute(r.ctx, input) r.lock.Lock() if err != nil { diff --git a/internal/step/lifecycle.go b/internal/step/lifecycle.go index dfd58574..83495250 100644 --- a/internal/step/lifecycle.go +++ b/internal/step/lifecycle.go @@ -49,7 +49,7 @@ func (l Lifecycle[StageType]) DAG() (dgraph.DirectedGraph[StageType], error) { // lifecycleStage is a helper interface for being able to construct a DAG from a lifecycle. type lifecycleStage interface { - // Identifier returns the Name of the stage. + // Identifier returns the ID of the stage. Identifier() string // NextStageIDs returns the next stage identifiers. NextStageIDs() []string diff --git a/internal/step/plugin/provider.go b/internal/step/plugin/provider.go index 4833bd38..bff40e82 100644 --- a/internal/step/plugin/provider.go +++ b/internal/step/plugin/provider.go @@ -360,7 +360,7 @@ func (r *runnableStep) Lifecycle(input map[string]any) (result step.Lifecycle[st cancelSignal := stepSchema.SignalHandlers()[plugin.CancellationSignalSchema.ID()] if cancelSignal == nil { // Not present - stopIfProperty.Disable(fmt.Sprintf("Cancel signal with Name '%s' is not present in plugin '%s', step '%s'. Signal handler IDs present: %v", + stopIfProperty.Disable(fmt.Sprintf("Cancel signal with ID '%s' is not present in plugin '%s', step '%s'. Signal handler IDs present: %v", plugin.CancellationSignalSchema.ID(), r.source, stepID, reflect.ValueOf(stepSchema.SignalHandlers()).MapKeys())) } else if err := plugin.CancellationSignalSchema.DataSchemaValue.ValidateCompatibility(cancelSignal.DataSchemaValue); err != nil { // Present but incompatible diff --git a/internal/step/plugin/provider_test.go b/internal/step/plugin/provider_test.go index c4276a09..6d749224 100644 --- a/internal/step/plugin/provider_test.go +++ b/internal/step/plugin/provider_test.go @@ -33,13 +33,13 @@ func (s *deployFailStageChangeHandler) OnStepComplete( panic(fmt.Errorf("invalid previous stage: %s", previousStage)) } if previousStageOutputID == nil { - panic(fmt.Errorf("no previous stage output Name")) + panic(fmt.Errorf("no previous stage output ID")) } if *previousStageOutputID != "error" { - panic(fmt.Errorf("invalid previous stage output Name: %s", *previousStageOutputID)) + panic(fmt.Errorf("invalid previous stage output ID: %s", *previousStageOutputID)) } if previousStageOutput == nil { - panic(fmt.Errorf("no previous stage output Name")) + panic(fmt.Errorf("no previous stage output ID")) } message := (*previousStageOutput).(plugin.DeployFailed).Error @@ -65,13 +65,13 @@ func (s *startFailStageChangeHandler) OnStepComplete( panic(fmt.Errorf("invalid previous stage: %s", previousStage)) } if previousStageOutputID == nil { - panic(fmt.Errorf("no previous stage output Name")) + panic(fmt.Errorf("no previous stage output ID")) } if *previousStageOutputID != "error" { panic(fmt.Errorf("invalid previous stage output Name: %s", *previousStageOutputID)) } if previousStageOutput == nil { - panic(fmt.Errorf("no previous stage output Name")) + panic(fmt.Errorf("no previous stage output ID")) } message := (*previousStageOutput).(plugin.Crashed).Output @@ -98,13 +98,13 @@ func (s *stageChangeHandler) OnStepComplete( panic(fmt.Errorf("invalid previous stage: %s", previousStage)) } if previousStageOutputID == nil { - panic(fmt.Errorf("no previous stage output Name")) + panic(fmt.Errorf("no previous stage output ID")) } if *previousStageOutputID != "success" { - panic(fmt.Errorf("invalid previous stage output Name: %s", *previousStageOutputID)) + panic(fmt.Errorf("invalid previous stage output ID: %s", *previousStageOutputID)) } if previousStageOutput == nil { - panic(fmt.Errorf("no previous stage output Name")) + panic(fmt.Errorf("no previous stage output ID")) } message := (*previousStageOutput).(map[any]any)["message"].(string) diff --git a/workflow/executor.go b/workflow/executor.go index 02a6462c..f1a4add4 100644 --- a/workflow/executor.go +++ b/workflow/executor.go @@ -58,7 +58,7 @@ type ExecutableWorkflow interface { // Execute runs a workflow until it finishes or until the context expires with the specified input. The input // must only contain primitives (float, int, bool, string, map, slice) and may not contain structs and other - // elements. The output will consist of the output Name, the returned output data corresponding to the output IDs + // elements. The output will consist of the output ID, the returned output data corresponding to the output IDs // schema, or if an error happened, the error. Execute( ctx context.Context, diff --git a/workflow/model.go b/workflow/model.go index 3efe3b22..5ff2b02a 100644 --- a/workflow/model.go +++ b/workflow/model.go @@ -21,7 +21,7 @@ type Workflow struct { // Steps contains the possible steps in this workflow. The data set must contain a valid step structure where the // inputs to stages may consist only of primitive types and expressions. Steps map[string]any `json:"steps"` - // Outputs lets you define one or more outputs. The outputs should be keyed by their output Name (e.g. "success") and + // Outputs lets you define one or more outputs. The outputs should be keyed by their output ID (e.g. "success") and // the value should be the data you wish to output. The data may contain expressions to construct the output. Outputs map[string]any `json:"outputs"` // OutputSchema is an optional override for the automatically inferred output schema from the Outputs data and @@ -182,7 +182,7 @@ type DAGItem struct { StepID string // StageID is the stage of the step provider this item refers to. StageID string - // OutputID is the Name of the output of the step stage. + // OutputID is the ID of the output of the step stage. OutputID string // OutputSchema contains the output-specific schema for this item. OutputSchema schema.StepOutput @@ -212,12 +212,12 @@ func (d DAGItem) String() string { } } -// GetStageNodeID returns the DAG node Name for a stage. +// GetStageNodeID returns the DAG node ID for a stage. func GetStageNodeID(stepID string, stageID string) string { return fmt.Sprintf("steps.%s.%s", stepID, stageID) } -// GetOutputNodeID returns the DAG node Name for a stage output. +// GetOutputNodeID returns the DAG node ID for a stage output. func GetOutputNodeID(stepID string, stageID string, outputID string) string { return fmt.Sprintf("steps.%s.%s.%s", stepID, stageID, outputID) } diff --git a/workflow/workflow.go b/workflow/workflow.go index 4e962576..9ffab54d 100644 --- a/workflow/workflow.go +++ b/workflow/workflow.go @@ -260,31 +260,31 @@ func (l *loopState) onStageComplete(stepID string, previousStage *string, previo } stageNode, err := l.dag.GetNodeByID(GetStageNodeID(stepID, *previousStage)) if err != nil { - l.logger.Errorf("Failed to get stage node Name %s (%w)", GetStageNodeID(stepID, *previousStage), err) - l.recentErrors <- fmt.Errorf("failed to get stage node Name %s (%w)", GetStageNodeID(stepID, *previousStage), err) + l.logger.Errorf("Failed to get stage node ID %s (%w)", GetStageNodeID(stepID, *previousStage), err) + l.recentErrors <- fmt.Errorf("failed to get stage node ID %s (%w)", GetStageNodeID(stepID, *previousStage), err) l.cancel() return } l.logger.Debugf("Removed node '%s' from the DAG", stageNode.ID()) if err := stageNode.Remove(); err != nil { - l.logger.Errorf("Failed to remove stage node Name %s (%w)", stageNode.ID(), err) - l.recentErrors <- fmt.Errorf("failed to remove stage node Name %s (%w)", stageNode.ID(), err) + l.logger.Errorf("Failed to remove stage node ID %s (%w)", stageNode.ID(), err) + l.recentErrors <- fmt.Errorf("failed to remove stage node ID %s (%w)", stageNode.ID(), err) l.cancel() return } if previousStageOutputID != nil { outputNode, err := l.dag.GetNodeByID(GetOutputNodeID(stepID, *previousStage, *previousStageOutputID)) if err != nil { - l.logger.Errorf("Failed to get output node Name %s (%w)", GetStageNodeID(stepID, *previousStage), err) - l.recentErrors <- fmt.Errorf("failed to get output node Name %s (%w)", GetStageNodeID(stepID, *previousStage), err) + l.logger.Errorf("Failed to get output node ID %s (%w)", GetStageNodeID(stepID, *previousStage), err) + l.recentErrors <- fmt.Errorf("failed to get output node ID %s (%w)", GetStageNodeID(stepID, *previousStage), err) l.cancel() return } // Removes the node from the DAG. This results in the nodes not having inbound connections, allowing them to be processed. l.logger.Debugf("Removed node '%s' from the DAG", outputNode.ID()) if err := outputNode.Remove(); err != nil { - l.logger.Errorf("Failed to remove output node Name %s (%w)", outputNode.ID(), err) - l.recentErrors <- fmt.Errorf("failed to remove output node Name %s (%w)", outputNode.ID(), err) + l.logger.Errorf("Failed to remove output node ID %s (%w)", outputNode.ID(), err) + l.recentErrors <- fmt.Errorf("failed to remove output node ID %s (%w)", outputNode.ID(), err) l.cancel() return } @@ -293,7 +293,7 @@ func (l *loopState) onStageComplete(stepID string, previousStage *string, previo if stepLogConfig != nil { l.logger.Writef( stepLogConfig.LogLevel, - "Output Name for step \"%s\" is \"%s\".\nOutput data: \"%s\"", + "Output ID for step \"%s\" is \"%s\".\nOutput data: \"%s\"", stepID, *previousStageOutputID, *previousStageOutput, @@ -362,7 +362,7 @@ func (l *loopState) notifySteps() { //nolint:gocognit // This check is here just to make sure it has the required fields set if node.Item().StepID == "" || node.Item().StageID == "" { // This shouldn't happen - panic("Step or stage Name missing") + panic("Step or stage ID missing") } stageInputData := untypedInputData.(map[any]any)