-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: execution plan and workflow driver
Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
- Loading branch information
Showing
4 changed files
with
121 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package workflow | ||
|
||
// ExecutionPlan outlines the set of tasks required to execute a bundle | ||
// and indicates when tasks may run in parallel. | ||
type ExecutionPlan struct { | ||
// Ordered list of tasks | ||
Tasks TaskSet | ||
|
||
// debugMode indicates that Porter is going to step through the workflow a task at a time | ||
// This indicates that the workflow driver should generate a workflow definition that supports debugging. | ||
DebugMode bool | ||
} | ||
|
||
type ExecutionOptions struct { | ||
// DebugMode indicates that Porter is going to step through the workflow a task at a time | ||
// This indicates that the workflow driver should generate a workflow definition that supports debugging. | ||
DebugMode bool | ||
} | ||
|
||
func NewExecutionPlan(nodes []Node, opts ExecutionOptions) ExecutionPlan { | ||
return ExecutionPlan{ | ||
Tasks: nil, | ||
DebugMode: opts.DebugMode, | ||
} | ||
} | ||
|
||
// TaskList is an ordered list of tasks. | ||
type TaskList []Task | ||
|
||
// TaskSet contains groups of tasks that can be run in parallel. | ||
type TaskSet []TaskList | ||
|
||
type Task struct { | ||
// Name of the task. Used to refer to a task output | ||
Name string | ||
|
||
// InstallerType defines the type of the installer: docker image, webassembly module, etc. | ||
InstallerType string | ||
|
||
// InstallerReference fully qualified reference to the definition of the installer. | ||
InstallerReference string | ||
|
||
// Inputs given to the task | ||
Inputs []TaskInput | ||
|
||
// Outputs that were generated by the task | ||
Outputs map[string]TaskOutput | ||
} | ||
|
||
type TaskInput struct { | ||
// Env is the name of the environment variable to inject | ||
Env string | ||
|
||
// Path is the full path of the file to inject | ||
Path string | ||
|
||
// Contents of the input value. | ||
Contents string | ||
|
||
// Source where the contents can be resolved. Guaranteed that the source is resolvable when the task is run. | ||
Source string | ||
} | ||
|
||
type TaskOutput struct { | ||
// Path is the full path of the file to collect. | ||
Path string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package workflow | ||
|
||
import "context" | ||
|
||
// WorkflowDriver is how Porter interacts with workflow drivers, e.g. argo, cadence, etc. | ||
type WorkflowDriver interface { | ||
// CreateWorkflow converts the ExecutionPlan into a definition that the driver understands. | ||
CreateWorkflow(ctx context.Context, plan ExecutionPlan) (WorkflowDefinition, error) | ||
|
||
// StartWorkflow begins the specified workflow. | ||
StartWorkflow(ctx context.Context, workflow WorkflowDefinition) error | ||
|
||
// CancelWorkflow stops the specified workflow. | ||
CancelWorkflow(ctx context.Context, workflow WorkflowDefinition) error | ||
|
||
// RetryWorkflow starts the workflow over at the last failed job(s). | ||
RetryWorkflow(ctx context.Context, workflow WorkflowDefinition) error | ||
|
||
// StepThrough runs only the specified task in the workflow, pausing afterwards so that the workflow can be debugged. | ||
StepThrough(ctx context.Context, workflow WorkflowDefinition, taskName string) error | ||
} | ||
|
||
// WorkflowDefinition is the representation of the ExecutionPlan against a specific workflow driver. | ||
type WorkflowDefinition map[string]interface{} |