Documentation
¶
Index ¶
- func FindAvailablePort(preferredPort int) (int, error)
- func HasTemplates(s string) bool
- func IsPortAvailable(port int) bool
- type BuildImageOptions
- type BuiltImage
- type Docker
- func (d *Docker) BuildImage(ctx context.Context, opts BuildImageOptions) (string, error)
- func (d *Docker) ContainerExists(ctx context.Context, containerName string) bool
- func (d *Docker) CreateNetwork(ctx context.Context, opts NetworkCreateOptions) error
- func (d *Docker) GetContainerLogs(ctx context.Context, containerName string, lines int) (string, error)
- func (d *Docker) GetImageID(ctx context.Context, imageName string) (string, error)
- func (d *Docker) ImageExists(ctx context.Context, imageName string) bool
- func (d *Docker) IsContainerRunning(ctx context.Context, containerName string) bool
- func (d *Docker) NetworkExists(ctx context.Context, name string) bool
- func (d *Docker) PullImage(ctx context.Context, imageName string) error
- func (d *Docker) RemoveContainer(ctx context.Context, containerName string) error
- func (d *Docker) RemoveExistingContainer(ctx context.Context, containerName string) error
- func (d *Docker) RemoveNetwork(ctx context.Context, name string) error
- func (d *Docker) RunContainer(ctx context.Context, opts RunContainerOptions) error
- func (d *Docker) SetSecrets(secrets []string)
- func (d *Docker) StopContainer(ctx context.Context, containerName string) error
- func (d *Docker) StreamLogs(ctx context.Context, containerName string) error
- type DotEnv
- type ExposedService
- type FileWatcher
- type HealthCheckConfig
- type JobMeta
- type NetworkCreateOptions
- type PortMapping
- type Reloader
- type ResolvedVolume
- type RunContainerOptions
- type Runner
- func (r *Runner) Run(ctx context.Context, ocw *schema.OCW) error
- func (r *Runner) RunJob(ctx context.Context, ocw *schema.OCW, jobName string) error
- func (r *Runner) WithEnvFile(envFile string) *Runner
- func (r *Runner) WithForce(force bool) *Runner
- func (r *Runner) WithShowSecrets(show bool) *Runner
- type StepResult
- type StepStatus
- type Styles
- func (s *Styles) Box(title, content string) string
- func (s *Styles) Command(text string) string
- func (s *Styles) CompletionBanner(jobName string, duration string, success bool) string
- func (s *Styles) Dim(text string) string
- func (s *Styles) Divider(width int) string
- func (s *Styles) Duration(d string) string
- func (s *Styles) Error(text string) string
- func (s *Styles) Header(text string) string
- func (s *Styles) Icon(icon string) string
- func (s *Styles) Info(text string) string
- func (s *Styles) JobBox(jobName, workflowName, description string) string
- func (s *Styles) JobHeader(text string) string
- func (s *Styles) Label(text string) string
- func (s *Styles) LogPrefix() string
- func (s *Styles) OutputKey(text string) string
- func (s *Styles) OutputValue(text string) string
- func (s *Styles) OutputsBox(title string, outputs map[string]string) string
- func (s *Styles) SectionHeader(text string) string
- func (s *Styles) ServiceURL(name, url, protocol string) string
- func (s *Styles) StatusIcon(status StepStatus) string
- func (s *Styles) StepBox(name, stepType string, extra map[string]string) string
- func (s *Styles) StepComplete(name string, success bool) string
- func (s *Styles) StepHeader(text string) string
- func (s *Styles) StepName(text string) string
- func (s *Styles) Success(text string) string
- func (s *Styles) Value(text string) string
- func (s *Styles) Warning(text string) string
- type TemplateContext
- func (tc *TemplateContext) GetStepOutput(stepID, key string) (string, bool)
- func (tc *TemplateContext) Interpolate(s string) (string, error)
- func (tc *TemplateContext) InterpolateMap(m map[string]string) (map[string]string, error)
- func (tc *TemplateContext) InterpolateSlice(s []string) ([]string, error)
- func (tc *TemplateContext) SetStepOutput(stepID, key, value string)
- type VolumeMount
- type WatchedContainer
- type WorkflowMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAvailablePort ¶
FindAvailablePort finds an available port, preferring the requested port. If the requested port is in use, it finds a random available port. Returns the actual port that will be used.
func HasTemplates ¶
HasTemplates checks if a string contains template expressions
func IsPortAvailable ¶
IsPortAvailable checks if a port is available on the host
Types ¶
type BuildImageOptions ¶
type BuildImageOptions struct {
ImageName string // Primary image tag
Context string // Build context path
Dockerfile string // Dockerfile path (relative to context)
BuildArgs map[string]string // Build arguments
Target string // Multi-stage build target
Tags []string // Additional tags
WorkflowDir string // Host path that serves as /workflow reference
VolumeMounts []VolumeMount // Additional volume mounts during build
}
BuildImageOptions holds options for building an image
type BuiltImage ¶
BuiltImage tracks images built during workflow execution
type Docker ¶
type Docker struct {
// Output function for logging
Output func(format string, args ...any)
// contains filtered or unexported fields
}
Docker wraps docker CLI commands
func (*Docker) BuildImage ¶
BuildImage builds an image using docker build
func (*Docker) ContainerExists ¶
ContainerExists checks if a container with the given name exists (running or stopped)
func (*Docker) CreateNetwork ¶
func (d *Docker) CreateNetwork(ctx context.Context, opts NetworkCreateOptions) error
CreateNetwork creates a Docker network
func (*Docker) GetContainerLogs ¶
func (d *Docker) GetContainerLogs(ctx context.Context, containerName string, lines int) (string, error)
GetContainerLogs returns the last n lines of container logs
func (*Docker) GetImageID ¶
GetImageID returns the image ID for a given image name
func (*Docker) ImageExists ¶
ImageExists checks if an image exists locally
func (*Docker) IsContainerRunning ¶
IsContainerRunning checks if a container is running
func (*Docker) NetworkExists ¶
NetworkExists checks if a network exists
func (*Docker) RemoveContainer ¶
RemoveContainer removes a container
func (*Docker) RemoveExistingContainer ¶
RemoveExistingContainer removes an existing container with the given name if it exists
func (*Docker) RemoveNetwork ¶
RemoveNetwork removes a Docker network
func (*Docker) RunContainer ¶
func (d *Docker) RunContainer(ctx context.Context, opts RunContainerOptions) error
RunContainer runs a container and waits for it to complete
func (*Docker) SetSecrets ¶
SetSecrets updates the secrets to mask in output
func (*Docker) StopContainer ¶
StopContainer stops a running container
type DotEnv ¶
DotEnv holds parsed environment variables from .env files
func LoadDotEnv ¶
LoadDotEnv loads environment variables from .env file in the workflow directory. If no .env file exists, returns an empty DotEnv (not an error). Lines starting with # are comments, empty lines are ignored. Format: KEY=value (no export prefix, quotes are preserved as-is)
func LoadDotEnvFile ¶
LoadDotEnvFile loads environment variables from a specific .env file. If the file doesn't exist, returns an empty DotEnv (not an error). Lines starting with # are comments, empty lines are ignored. Format: KEY=value (no export prefix, quotes are preserved as-is)
type ExposedService ¶
type ExposedService struct {
StepID string // ID of the step (used as identifier)
StepName string // Human-readable name of the step
ContainerPort int // Port inside the container
HostPort int // Port on the host (may differ if preferred port was unavailable)
RequestedPort int // Originally requested host port
Protocol string // Protocol (http, https, tcp, udp)
}
ExposedService tracks a service that has been exposed to the host
type FileWatcher ¶
type FileWatcher struct {
// contains filtered or unexported fields
}
FileWatcher watches for file system changes and triggers callbacks
func NewFileWatcher ¶
func NewFileWatcher(watchConfig *schema.Watch, basePath string, onChange func(changedFile string)) (*FileWatcher, error)
NewFileWatcher creates a new file watcher
type HealthCheckConfig ¶
type HealthCheckConfig struct {
Cmd string // Command to run for health check
Interval time.Duration // Time between health checks
Timeout time.Duration // Timeout for each health check
Retries int // Number of retries before failing
StartPeriod time.Duration // Grace period before starting health checks
}
HealthCheckConfig holds health check configuration
type NetworkCreateOptions ¶
type NetworkCreateOptions struct {
Name string // Network name
Driver string // Network driver (default: bridge)
}
NetworkCreateOptions holds options for creating a network
type PortMapping ¶
type PortMapping struct {
ContainerPort int // Port inside the container
HostPort int // Port on the host
Protocol string // Protocol (http, https, tcp, udp)
}
PortMapping represents a container port to host port mapping
type Reloader ¶
type Reloader struct {
// contains filtered or unexported fields
}
Reloader manages file watchers and container reloading
func (*Reloader) RegisterContainer ¶
func (r *Reloader) RegisterContainer(wc *WatchedContainer) error
RegisterContainer registers a container for watching
type ResolvedVolume ¶
type ResolvedVolume struct {
Name string
HostPath string // Absolute path on host
Mode schema.VolumeMode // "ro" or "rw"
MountPath string // Default mount path (empty = /volumes/<name>)
}
ResolvedVolume contains the resolved paths for a workflow volume
type RunContainerOptions ¶
type RunContainerOptions struct {
Name string // Container name (optional, auto-generated if empty)
Hostname string // Hostname for the container (for DNS resolution in network)
Network string // Network to connect to (empty = default docker network)
Image string // Image to run
Cmd string // Command string (will be passed to shell)
Args []string // Command arguments (if Cmd is empty)
Entrypoint string // Override entrypoint
Env map[string]string // Environment variables
WorkDir string // Working directory inside container
WorkflowDir string // Host path to mount as /workflow
VolumeMounts []VolumeMount // Additional volume mounts (for explicit host access)
TTY bool // Allocate TTY
Remove bool // Remove container after exit (default true for non-background)
Background bool // Run in background (detached)
HealthCheck *HealthCheckConfig // Health check for background containers
PortMappings []PortMapping // Ports to expose from container to host
Force bool // Force remove existing container with same name
}
RunContainerOptions holds options for running a container
type Runner ¶
type Runner struct {
// WorkflowDir is the directory containing the workflow file (mounted as /workflow)
WorkflowDir string
// WorkflowFile is the path to the workflow YAML file
WorkflowFile string
// EnvFile is the path to the .env file to load (empty means use default .env)
EnvFile string
// Output function for logging (defaults to fmt.Printf)
Output func(format string, args ...any)
// contains filtered or unexported fields
}
Runner executes OCW workflows
func (*Runner) WithEnvFile ¶
WithEnvFile sets a custom .env file path
func (*Runner) WithForce ¶
WithForce sets whether to force remove existing containers with the same name
func (*Runner) WithShowSecrets ¶
WithShowSecrets sets whether to show secret values in output (disable masking)
type StepResult ¶
type StepResult struct {
Name string
Status StepStatus
Duration time.Duration
Error error
}
StepResult represents the result of a step execution
type StepStatus ¶
type StepStatus string
StepStatus represents the status of a step
const ( StepStatusPending StepStatus = "pending" StepStatusRunning StepStatus = "running" StepStatusCompleted StepStatus = "completed" StepStatusFailed StepStatus = "failed" StepStatusSkipped StepStatus = "skipped" )
type Styles ¶
type Styles struct {
// contains filtered or unexported fields
}
Styles provides pre-defined styles for different output types
func NewStyles ¶
func NewStyles() *Styles
NewStyles creates a new Styles instance, auto-detecting color support
func (*Styles) CompletionBanner ¶
CompletionBanner creates the final completion banner
func (*Styles) OutputValue ¶
OutputValue styles output values
func (*Styles) OutputsBox ¶
OutputsBox creates a styled outputs section
func (*Styles) SectionHeader ¶
SectionHeader creates a section header (like ">>> Running 4 steps in sequence")
func (*Styles) ServiceURL ¶
ServiceURL formats a service URL
func (*Styles) StatusIcon ¶
func (s *Styles) StatusIcon(status StepStatus) string
StatusIcon returns an appropriate icon for a status
func (*Styles) StepComplete ¶
StepComplete formats a step completion message
func (*Styles) StepHeader ¶
StepHeader styles step headers
type TemplateContext ¶
type TemplateContext struct {
// Steps contains outputs from completed steps, keyed by step ID
// Each step can have multiple outputs (e.g., "image" for build steps)
Steps map[string]map[string]string
// Env contains environment variables (workflow-level + system)
Env map[string]string
// Workflow contains workflow metadata
Workflow WorkflowMeta
// Job contains current job metadata
Job JobMeta
}
TemplateContext holds the data available for template interpolation
func NewTemplateContext ¶
func NewTemplateContext() *TemplateContext
NewTemplateContext creates a new empty template context
func (*TemplateContext) GetStepOutput ¶
func (tc *TemplateContext) GetStepOutput(stepID, key string) (string, bool)
GetStepOutput gets an output value for a step
func (*TemplateContext) Interpolate ¶
func (tc *TemplateContext) Interpolate(s string) (string, error)
Interpolate replaces template expressions in a string with their values
func (*TemplateContext) InterpolateMap ¶
InterpolateMap interpolates all string values in a map
func (*TemplateContext) InterpolateSlice ¶
func (tc *TemplateContext) InterpolateSlice(s []string) ([]string, error)
InterpolateSlice interpolates all strings in a slice
func (*TemplateContext) SetStepOutput ¶
func (tc *TemplateContext) SetStepOutput(stepID, key, value string)
SetStepOutput sets an output value for a step
type VolumeMount ¶
VolumeMount represents a resolved volume mount
type WatchedContainer ¶
type WatchedContainer struct {
StepID string
StepName string
Image string
ContainerName string
WatchConfig *schema.Watch
RunStep *schema.RunStep
BuildStepID string // ID of the build step if using a built image
// Volume mounts for translating container paths to host paths
VolumeMounts []VolumeMount
PortMappings []PortMapping // Track allocated ports to reuse them on reload
// contains filtered or unexported fields
}
WatchedContainer tracks a container being watched for file changes
type WorkflowMeta ¶
WorkflowMeta contains workflow-level metadata