Documentation
¶
Index ¶
- func CheckAndGenerateWorkflowStepNames(workflowDefinition *schema.WorkflowDefinition)
- type AtmosExecParams
- type AtmosExecutor
- type AuthProvider
- type CommandRunner
- type DefaultCommandRunner
- type ExecuteOptions
- type ExecutionResult
- type Executor
- type ShellExecutor
- type StepResult
- type UIProvider
- type WorkflowLoader
- type WorkflowParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAndGenerateWorkflowStepNames ¶
func CheckAndGenerateWorkflowStepNames(workflowDefinition *schema.WorkflowDefinition)
CheckAndGenerateWorkflowStepNames generates step names for steps that don't have them. If a step doesn't have a name, it generates one in the format "step1", "step2", etc.
Types ¶
type AtmosExecParams ¶
type AtmosExecParams struct {
// Ctx is the context for cancellation.
Ctx context.Context
// AtmosConfig is the atmos configuration.
AtmosConfig *schema.AtmosConfiguration
// Args are command arguments (e.g., ["terraform", "plan", "vpc"]).
Args []string
// Dir is the working directory for the command.
Dir string
// Env are environment variables for the command.
Env []string
// DryRun if true, don't actually execute the command.
DryRun bool
}
AtmosExecParams holds parameters for executing an atmos command.
type AtmosExecutor ¶
type AtmosExecutor func(params *AtmosExecParams) error
AtmosExecutor is a function type for executing atmos commands. This type allows injecting the actual atmos execution function.
type AuthProvider ¶
type AuthProvider interface {
// NeedsAuth returns true if authentication is needed for the given steps.
NeedsAuth(steps []schema.WorkflowStep, commandLineIdentity string) bool
// Authenticate performs authentication for the given identity.
// Returns an error if authentication fails.
Authenticate(ctx context.Context, identity string) error
// GetCachedCredentials returns cached credentials for the identity.
// Returns an error if no valid cached credentials are available.
GetCachedCredentials(ctx context.Context, identity string) (any, error)
// PrepareEnvironment prepares environment variables for the authenticated identity.
// Returns the modified environment slice.
PrepareEnvironment(ctx context.Context, identity string, baseEnv []string) ([]string, error)
}
AuthProvider abstracts authentication operations for workflow steps. This interface enables testing identity-based workflows without real auth providers.
type CommandRunner ¶
type CommandRunner interface {
// RunShell executes a shell command with the given parameters.
// Parameters:
// - command: The shell command to execute
// - name: A name for the command (for logging/identification)
// - dir: Working directory for the command
// - env: Environment variables for the command
// - dryRun: If true, don't actually execute the command
// Returns an error if the command fails.
RunShell(command, name, dir string, env []string, dryRun bool) error
// RunAtmos executes an atmos command with the given parameters.
// Returns an error if the command fails.
RunAtmos(params *AtmosExecParams) error
}
CommandRunner abstracts the execution of shell and atmos commands. This interface enables testing workflow logic without spawning real processes.
type DefaultCommandRunner ¶
type DefaultCommandRunner struct {
// contains filtered or unexported fields
}
DefaultCommandRunner is the default implementation of CommandRunner that delegates to the provided shell and atmos execution functions. This is designed for dependency injection - the actual execution functions must be provided by the caller (typically from internal/exec).
func NewDefaultCommandRunner ¶
func NewDefaultCommandRunner(shellExec ShellExecutor, atmosExec AtmosExecutor) *DefaultCommandRunner
NewDefaultCommandRunner creates a new DefaultCommandRunner with the given executors. Both executors should be provided - nil executors will result in ErrNilParam being returned.
func (*DefaultCommandRunner) RunAtmos ¶
func (r *DefaultCommandRunner) RunAtmos(params *AtmosExecParams) error
RunAtmos executes an atmos command using the configured atmos executor.
type ExecuteOptions ¶
type ExecuteOptions struct {
// DryRun if true, commands are not actually executed.
DryRun bool
// CommandLineStack overrides the stack for all steps.
CommandLineStack string
// FromStep skips steps until this step name is reached.
FromStep string
// CommandLineIdentity sets the identity for steps without explicit identity.
CommandLineIdentity string
}
ExecuteOptions contains options for workflow execution.
type ExecutionResult ¶
type ExecutionResult struct {
// WorkflowName is the name of the workflow.
WorkflowName string
// Steps contains results for each step.
Steps []StepResult
// Success indicates whether all steps succeeded.
Success bool
// Error is the first error encountered, if any.
Error error
// ResumeCommand is the command to resume from the failed step.
ResumeCommand string
}
ExecutionResult represents the result of executing a complete workflow.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor handles workflow execution with dependency injection for testing.
func NewExecutor ¶
func NewExecutor(runner CommandRunner, authProvider AuthProvider, ui UIProvider) *Executor
NewExecutor creates a new Executor with the given dependencies. Nil dependencies are handled gracefully: runner is required for command execution, authProvider can be nil if no authentication is needed, and ui can be nil to disable user-facing output (messages and errors will be silently skipped).
func (*Executor) Execute ¶
func (e *Executor) Execute(params *WorkflowParams) (*ExecutionResult, error)
Execute runs a workflow with the given options. This is the main entry point for workflow execution.
type ShellExecutor ¶
ShellExecutor is a function type for executing shell commands. This type allows injecting the actual shell execution function.
type StepResult ¶
type StepResult struct {
// StepName is the name of the step.
StepName string
// Command is the command that was executed.
Command string
// Success indicates whether the step succeeded.
Success bool
// Error is the error if the step failed.
Error error
// Skipped indicates if the step was skipped (e.g., due to --from-step).
Skipped bool
}
StepResult represents the result of executing a single workflow step.
type UIProvider ¶
type UIProvider interface {
// PrintMessage prints a message to the user.
PrintMessage(format string, args ...any)
// PrintError prints an error message to the user.
PrintError(err error, title, explanation string)
}
UIProvider abstracts user interface operations for workflows. This interface enables testing without terminal interaction.
type WorkflowLoader ¶
type WorkflowLoader interface {
// LoadWorkflow loads a workflow definition from the given path.
// Parameters:
// - atmosConfig: The atmos configuration
// - workflowPath: Path to the workflow file
// - workflowName: Name of the workflow to load
// Returns the workflow definition and any error.
LoadWorkflow(atmosConfig *schema.AtmosConfiguration, workflowPath, workflowName string) (*schema.WorkflowDefinition, error)
// ListWorkflows returns all available workflows.
ListWorkflows(atmosConfig *schema.AtmosConfiguration) ([]schema.DescribeWorkflowsItem, error)
}
WorkflowLoader abstracts loading and parsing workflow definitions. This interface enables testing without file system access.
type WorkflowParams ¶
type WorkflowParams struct {
// Ctx is the context for cancellation.
Ctx context.Context
// AtmosConfig is the atmos configuration.
AtmosConfig *schema.AtmosConfiguration
// Workflow is the name of the workflow.
Workflow string
// WorkflowPath is the path to the workflow file.
WorkflowPath string
// WorkflowDefinition is the parsed workflow definition.
WorkflowDefinition *schema.WorkflowDefinition
// Opts are the execution options.
Opts ExecuteOptions
}
WorkflowParams contains parameters for workflow execution.