Documentation
¶
Index ¶
- type ApplyOpts
- type BlueGreenState
- type BlueGreenStrategy
- func (s *BlueGreenStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
- func (s *BlueGreenStrategy) GetState(workflowID string) (*BlueGreenState, bool)
- func (s *BlueGreenStrategy) Name() string
- func (s *BlueGreenStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)
- func (s *BlueGreenStrategy) Validate(config map[string]any) error
- type CanaryConfig
- type CanaryStrategy
- func (s *CanaryStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
- func (s *CanaryStrategy) GetSplit(workflowID string) (*TrafficSplit, bool)
- func (s *CanaryStrategy) Name() string
- func (s *CanaryStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)
- func (s *CanaryStrategy) SetHealthCheck(fn func(ctx context.Context, workflowID string, version int) (float64, error))
- func (s *CanaryStrategy) Validate(config map[string]any) error
- type Capabilities
- type ComposeSidecarSpec
- type DeployArtifacts
- type DeployRequest
- type DeployResult
- type DeployStatus
- type DeployTarget
- type DeployTargetRegistry
- type DeployedResource
- type DeploymentPlan
- type DeploymentResult
- type DeploymentStrategy
- type ECSSidecarSpec
- type Environment
- type K8sSidecarSpec
- type LogOpts
- type ResourceStatus
- type RollingConfig
- type RollingStrategy
- type SecretEnvVar
- type SecurityContext
- type SidecarProvider
- type SidecarRegistry
- type SidecarSpec
- type StrategyRegistry
- type TrafficSplit
- type Volume
- type VolumeMount
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApplyOpts ¶ added in v0.3.5
type ApplyOpts struct {
// DryRun simulates the apply without making changes.
DryRun bool `json:"dryRun,omitempty"`
// Wait blocks until the deployment is complete or times out.
Wait bool `json:"wait,omitempty"`
// WaitTimeout is the maximum time to wait for deployment completion.
WaitTimeout time.Duration `json:"waitTimeout,omitempty"`
// Force deletes and recreates resources that cannot be updated.
Force bool `json:"force,omitempty"`
// FieldManager is the field manager name for server-side apply.
FieldManager string `json:"fieldManager,omitempty"`
}
ApplyOpts configures how Apply behaves.
type BlueGreenState ¶
type BlueGreenState struct {
ActiveEnv Environment `json:"active_env"`
StandbyEnv Environment `json:"standby_env"`
ActiveVer int `json:"active_version"`
StandbyVer int `json:"standby_version"`
}
BlueGreenState tracks the current blue-green deployment state.
type BlueGreenStrategy ¶
type BlueGreenStrategy struct {
// contains filtered or unexported fields
}
BlueGreenStrategy implements zero-downtime deployments by swapping between two environments.
func NewBlueGreenStrategy ¶
func NewBlueGreenStrategy(logger *slog.Logger) *BlueGreenStrategy
NewBlueGreenStrategy creates a new BlueGreenStrategy.
func (*BlueGreenStrategy) Execute ¶
func (s *BlueGreenStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
Execute performs a blue-green deployment: deploy to standby, health check, then switch traffic.
func (*BlueGreenStrategy) GetState ¶
func (s *BlueGreenStrategy) GetState(workflowID string) (*BlueGreenState, bool)
GetState returns the current blue-green state for a workflow.
func (*BlueGreenStrategy) Name ¶
func (s *BlueGreenStrategy) Name() string
Name returns the strategy identifier.
func (*BlueGreenStrategy) Rollback ¶
func (s *BlueGreenStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)
Rollback switches traffic back to the previous environment.
type CanaryConfig ¶
type CanaryConfig struct {
InitialPercent float64 `json:"initial_percent"` // default 10
Increment float64 `json:"increment"` // default 20
Interval time.Duration `json:"interval"` // default 30s
ErrorThreshold float64 `json:"error_threshold"` // default 5 (percent)
}
CanaryConfig holds the tunable parameters for canary deployments.
func DefaultCanaryConfig ¶
func DefaultCanaryConfig() CanaryConfig
DefaultCanaryConfig returns the default canary configuration.
type CanaryStrategy ¶
type CanaryStrategy struct {
// contains filtered or unexported fields
}
CanaryStrategy implements gradual traffic-shifting deployments.
func NewCanaryStrategy ¶
func NewCanaryStrategy(logger *slog.Logger) *CanaryStrategy
NewCanaryStrategy creates a new CanaryStrategy.
func (*CanaryStrategy) Execute ¶
func (s *CanaryStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
Execute performs a canary deployment with gradual traffic shifting.
func (*CanaryStrategy) GetSplit ¶
func (s *CanaryStrategy) GetSplit(workflowID string) (*TrafficSplit, bool)
GetSplit returns the current traffic split for a workflow.
func (*CanaryStrategy) Name ¶
func (s *CanaryStrategy) Name() string
Name returns the strategy identifier.
func (*CanaryStrategy) Rollback ¶
func (s *CanaryStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)
Rollback immediately shifts all traffic back to the stable version.
func (*CanaryStrategy) SetHealthCheck ¶
func (s *CanaryStrategy) SetHealthCheck(fn func(ctx context.Context, workflowID string, version int) (float64, error))
SetHealthCheck sets a custom health check function for canary evaluation.
type Capabilities ¶ added in v0.3.5
type Capabilities struct {
Add []string `json:"add,omitempty"`
Drop []string `json:"drop,omitempty"`
}
Capabilities describes Linux capabilities to add or drop.
type ComposeSidecarSpec ¶ added in v0.3.5
type ComposeSidecarSpec struct {
Image string `json:"image"`
Command string `json:"command,omitempty"`
Environment map[string]string `json:"environment,omitempty"`
Ports []string `json:"ports,omitempty"`
Volumes []string `json:"volumes,omitempty"`
DependsOn []string `json:"dependsOn,omitempty"`
}
ComposeSidecarSpec contains Docker Compose-specific sidecar configuration.
type DeployArtifacts ¶ added in v0.3.5
type DeployArtifacts struct {
// Target is the deploy target name that generated these artifacts.
Target string `json:"target"`
// AppName is the application name.
AppName string `json:"appName"`
// Namespace is the target namespace/environment.
Namespace string `json:"namespace"`
// Files maps relative file paths to their content.
Files map[string][]byte `json:"files,omitempty"`
// Objects holds structured deployment objects (e.g., k8s unstructured objects).
Objects []any `json:"-"`
// Metadata holds target-specific metadata.
Metadata map[string]string `json:"metadata,omitempty"`
}
DeployArtifacts holds the generated deployment artifacts.
type DeployRequest ¶ added in v0.3.5
type DeployRequest struct {
Config *config.WorkflowConfig
Manifest *manifest.WorkflowManifest
Sidecars []*SidecarSpec
Image string
Namespace string
AppName string
Replicas int
ExtraEnv map[string]string
SecretRef string
OutputDir string
// Command overrides the container entrypoint.
Command []string
// Args overrides the default container arguments.
Args []string
// ImagePullPolicy sets the container image pull policy ("Never", "Always", "IfNotPresent").
ImagePullPolicy string
// Strategy sets the deployment strategy ("Recreate" or "RollingUpdate").
Strategy string
// ServiceAccount sets the pod service account name.
ServiceAccount string
// HealthPath overrides the default health check path ("/healthz").
HealthPath string
// ConfigMapName overrides the configmap name (default: AppName).
ConfigMapName string
// RunAsUser sets the pod security context runAsUser.
RunAsUser *int64
// RunAsNonRoot sets the pod security context runAsNonRoot.
RunAsNonRoot *bool
// FSGroup sets the pod security context fsGroup.
FSGroup *int64
// ConfigFileData is raw config YAML bytes (with env vars expanded).
// If set, used for ConfigMap instead of marshaling Config.
ConfigFileData []byte
}
DeployRequest bundles everything a DeployTarget needs to generate or apply.
type DeployResult ¶ added in v0.3.5
type DeployResult struct {
// Status is the deployment status ("success", "failed", "in_progress").
Status string `json:"status"`
// Message is a human-readable description of the result.
Message string `json:"message"`
// StartedAt is when the deployment started.
StartedAt time.Time `json:"startedAt"`
// CompletedAt is when the deployment finished.
CompletedAt time.Time `json:"completedAt"`
// Resources lists the resources that were created or updated.
Resources []DeployedResource `json:"resources,omitempty"`
}
DeployResult captures the outcome of a deploy apply operation.
type DeployStatus ¶ added in v0.3.5
type DeployStatus struct {
// AppName is the application name.
AppName string `json:"appName"`
// Namespace is the deployment namespace.
Namespace string `json:"namespace"`
// Phase is the overall deployment phase ("Running", "Pending", "Failed", "Unknown").
Phase string `json:"phase"`
// Ready is the number of ready replicas.
Ready int `json:"ready"`
// Desired is the desired number of replicas.
Desired int `json:"desired"`
// Message is additional status information.
Message string `json:"message,omitempty"`
// Resources lists individual resource statuses.
Resources []ResourceStatus `json:"resources,omitempty"`
}
DeployStatus represents the current state of a deployment.
type DeployTarget ¶ added in v0.3.5
type DeployTarget interface {
// Name returns the target identifier (e.g., "kubernetes", "ecs", "docker-compose").
Name() string
// Generate produces platform-specific deployment artifacts from config.
Generate(ctx context.Context, req *DeployRequest) (*DeployArtifacts, error)
// Apply deploys artifacts to the target platform.
Apply(ctx context.Context, artifacts *DeployArtifacts, opts ApplyOpts) (*DeployResult, error)
// Destroy tears down all resources for the given app.
Destroy(ctx context.Context, appName, namespace string) error
// Status returns current deployment status.
Status(ctx context.Context, appName, namespace string) (*DeployStatus, error)
// Diff compares generated artifacts against live state.
Diff(ctx context.Context, artifacts *DeployArtifacts) (string, error)
// Logs streams logs from the deployed app.
Logs(ctx context.Context, appName, namespace string, opts LogOpts) (io.ReadCloser, error)
}
DeployTarget is the interface that platform-specific deployers implement. Each target (kubernetes, ecs, docker-compose) provides Generate, Apply, Destroy, Status, Diff, and Logs operations.
type DeployTargetRegistry ¶ added in v0.3.5
type DeployTargetRegistry struct {
// contains filtered or unexported fields
}
DeployTargetRegistry holds registered deploy targets.
func NewDeployTargetRegistry ¶ added in v0.3.5
func NewDeployTargetRegistry() *DeployTargetRegistry
NewDeployTargetRegistry creates an empty deploy target registry.
func (*DeployTargetRegistry) Generate ¶ added in v0.3.5
func (r *DeployTargetRegistry) Generate(ctx context.Context, targetName string, req *DeployRequest) (*DeployArtifacts, error)
Generate is a convenience method that looks up a target and generates artifacts.
func (*DeployTargetRegistry) Get ¶ added in v0.3.5
func (r *DeployTargetRegistry) Get(name string) (DeployTarget, bool)
Get returns the deploy target with the given name.
func (*DeployTargetRegistry) List ¶ added in v0.3.5
func (r *DeployTargetRegistry) List() []string
List returns sorted names of all registered deploy targets.
func (*DeployTargetRegistry) Register ¶ added in v0.3.5
func (r *DeployTargetRegistry) Register(t DeployTarget)
Register adds a deploy target to the registry.
type DeployedResource ¶ added in v0.3.5
type DeployedResource struct {
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Status string `json:"status"`
}
DeployedResource describes a single deployed resource.
type DeploymentPlan ¶
type DeploymentPlan struct {
WorkflowID string `json:"workflow_id"`
FromVersion int `json:"from_version"`
ToVersion int `json:"to_version"`
Strategy string `json:"strategy"` // "rolling", "blue-green", "canary"
Config map[string]any `json:"config"`
}
DeploymentPlan describes a deployment to execute.
type DeploymentResult ¶
type DeploymentResult struct {
Status string `json:"status"` // "success", "failed", "rolled_back"
StartedAt time.Time `json:"started_at"`
CompletedAt time.Time `json:"completed_at"`
Message string `json:"message"`
RolledBack bool `json:"rolled_back"`
}
DeploymentResult captures the outcome of a deployment.
type DeploymentStrategy ¶
type DeploymentStrategy interface {
// Name returns the strategy identifier (e.g., "rolling", "blue-green", "canary").
Name() string
// Validate checks the strategy-specific configuration.
Validate(config map[string]any) error
// Execute runs the deployment according to the plan.
Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
}
DeploymentStrategy defines the interface for workflow deployment strategies.
type ECSSidecarSpec ¶ added in v0.3.5
type ECSSidecarSpec struct {
Image string `json:"image"`
Command []string `json:"command,omitempty"`
Env map[string]string `json:"env,omitempty"`
Essential bool `json:"essential"`
PortMappings []int32 `json:"portMappings,omitempty"`
}
ECSSidecarSpec contains ECS-specific sidecar configuration.
type Environment ¶
type Environment string
Environment identifies a blue-green deployment slot.
const ( EnvBlue Environment = "blue" EnvGreen Environment = "green" )
type K8sSidecarSpec ¶ added in v0.3.5
type K8sSidecarSpec struct {
Image string `json:"image"`
Command []string `json:"command,omitempty"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
SecretEnv []SecretEnvVar `json:"secretEnv,omitempty"`
Ports []int32 `json:"ports,omitempty"`
VolumeMounts []VolumeMount `json:"volumeMounts,omitempty"`
Volumes []Volume `json:"volumes,omitempty"`
ConfigMapData map[string]string `json:"configMapData,omitempty"`
ServiceAccountName string `json:"serviceAccountName,omitempty"`
RequiredSecrets []string `json:"requiredSecrets,omitempty"`
SecurityContext *SecurityContext `json:"securityContext,omitempty"`
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
}
K8sSidecarSpec contains Kubernetes-specific sidecar configuration.
type LogOpts ¶ added in v0.3.5
type LogOpts struct {
// Container filters logs to a specific container name.
Container string `json:"container,omitempty"`
// Follow streams logs as they are produced.
Follow bool `json:"follow,omitempty"`
// TailLines limits output to the last N lines.
TailLines int64 `json:"tailLines,omitempty"`
// Since only shows logs newer than this duration.
Since time.Duration `json:"since,omitempty"`
// Previous shows logs from previous container instances.
Previous bool `json:"previous,omitempty"`
}
LogOpts configures how Logs behaves.
type ResourceStatus ¶ added in v0.3.5
type ResourceStatus struct {
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Status string `json:"status"`
Message string `json:"message,omitempty"`
}
ResourceStatus describes the status of an individual deployed resource.
type RollingConfig ¶
type RollingConfig struct {
BatchSize int `json:"batch_size"` // default 1
Delay time.Duration `json:"delay"` // default 5s
}
RollingConfig holds the tunable parameters for rolling deployments.
func DefaultRollingConfig ¶
func DefaultRollingConfig() RollingConfig
DefaultRollingConfig returns the default rolling configuration.
type RollingStrategy ¶
type RollingStrategy struct {
// contains filtered or unexported fields
}
RollingStrategy implements simple rolling update deployments, updating instances one batch at a time.
func NewRollingStrategy ¶
func NewRollingStrategy(logger *slog.Logger) *RollingStrategy
NewRollingStrategy creates a new RollingStrategy.
func (*RollingStrategy) Execute ¶
func (s *RollingStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)
Execute performs a rolling deployment, processing instances in batches.
func (*RollingStrategy) Name ¶
func (s *RollingStrategy) Name() string
Name returns the strategy identifier.
type SecretEnvVar ¶ added in v0.3.5
type SecretEnvVar struct {
EnvName string `json:"envName"`
SecretName string `json:"secretName"`
SecretKey string `json:"secretKey"`
}
SecretEnvVar describes an environment variable sourced from a Kubernetes secret.
type SecurityContext ¶ added in v0.3.5
type SecurityContext struct {
RunAsUser *int64 `json:"runAsUser,omitempty"`
RunAsGroup *int64 `json:"runAsGroup,omitempty"`
Privileged *bool `json:"privileged,omitempty"`
Capabilities *Capabilities `json:"capabilities,omitempty"`
}
SecurityContext holds security settings for a sidecar container.
type SidecarProvider ¶ added in v0.3.5
type SidecarProvider interface {
// Type returns the sidecar type string (e.g., "sidecar.tailscale").
Type() string
// Validate checks the sidecar configuration.
Validate(cfg config.SidecarConfig) error
// Resolve produces a platform-specific SidecarSpec from config.
Resolve(cfg config.SidecarConfig, platform string) (*SidecarSpec, error)
}
SidecarProvider translates platform-agnostic SidecarConfig into platform-specific container specs.
type SidecarRegistry ¶ added in v0.3.5
type SidecarRegistry struct {
// contains filtered or unexported fields
}
SidecarRegistry holds registered sidecar providers.
func NewSidecarRegistry ¶ added in v0.3.5
func NewSidecarRegistry() *SidecarRegistry
NewSidecarRegistry creates an empty sidecar provider registry.
func (*SidecarRegistry) Get ¶ added in v0.3.5
func (r *SidecarRegistry) Get(typeName string) (SidecarProvider, bool)
Get returns the sidecar provider for the given type.
func (*SidecarRegistry) Register ¶ added in v0.3.5
func (r *SidecarRegistry) Register(p SidecarProvider)
Register adds a sidecar provider to the registry.
func (*SidecarRegistry) Resolve ¶ added in v0.3.5
func (r *SidecarRegistry) Resolve(sidecars []config.SidecarConfig, platform string) ([]*SidecarSpec, error)
Resolve resolves all sidecar configs into platform-specific specs.
type SidecarSpec ¶ added in v0.3.5
type SidecarSpec struct {
Name string
K8s *K8sSidecarSpec `json:"k8s,omitempty"`
ECS *ECSSidecarSpec `json:"ecs,omitempty"`
Compose *ComposeSidecarSpec `json:"compose,omitempty"`
}
SidecarSpec is the resolved, platform-specific sidecar output.
type StrategyRegistry ¶
type StrategyRegistry struct {
// contains filtered or unexported fields
}
StrategyRegistry holds the available deployment strategies.
func NewStrategyRegistry ¶
func NewStrategyRegistry(logger *slog.Logger) *StrategyRegistry
NewStrategyRegistry creates a registry pre-loaded with built-in strategies.
func (*StrategyRegistry) Execute ¶
func (r *StrategyRegistry) Execute(plan *DeploymentPlan) (*DeploymentResult, error)
Execute is a convenience method that looks up a strategy and executes a plan.
func (*StrategyRegistry) Get ¶
func (r *StrategyRegistry) Get(name string) (DeploymentStrategy, bool)
Get returns the strategy with the given name, or false if not found.
func (*StrategyRegistry) List ¶
func (r *StrategyRegistry) List() []string
List returns the sorted names of all registered strategies.
func (*StrategyRegistry) Register ¶
func (r *StrategyRegistry) Register(s DeploymentStrategy)
Register adds a strategy to the registry, replacing any existing one with the same name.
type TrafficSplit ¶
type TrafficSplit struct {
CanaryPercent float64 `json:"canary_percent"`
StablePercent float64 `json:"stable_percent"`
CanaryVersion int `json:"canary_version"`
StableVersion int `json:"stable_version"`
}
TrafficSplit tracks how traffic is distributed between versions.
type Volume ¶ added in v0.3.5
type Volume struct {
Name string `json:"name"`
EmptyDir bool `json:"emptyDir,omitempty"`
Secret string `json:"secret,omitempty"` //nolint:gosec // G117 — k8s secret name reference, not a secret value
ConfigMap string `json:"configMap,omitempty"`
}
Volume describes a volume for a sidecar container.
type VolumeMount ¶ added in v0.3.5
type VolumeMount struct {
Name string `json:"name"`
MountPath string `json:"mountPath"`
ReadOnly bool `json:"readOnly,omitempty"`
}
VolumeMount describes a volume mount for a sidecar container.