{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package deploy\n\n## Types\n\n```go\ntype ApplyOpts struct {\n\t// DryRun simulates the apply without making changes.\n\tDryRun bool `json:\"dryRun,omitempty\"`\n\t// Wait blocks until the deployment is complete or times out.\n\tWait bool `json:\"wait,omitempty\"`\n\t// WaitTimeout is the maximum time to wait for deployment completion.\n\tWaitTimeout time.Duration `json:\"waitTimeout,omitempty\"`\n\t// Force deletes and recreates resources that cannot be updated.\n\tForce bool `json:\"force,omitempty\"`\n\t// FieldManager is the field manager name for server-side apply.\n\tFieldManager string `json:\"fieldManager,omitempty\"`\n}\n```\nApplyOpts configures how Apply behaves.\n\n```go\ntype BlueGreenState struct {\n\tActiveEnv  Environment `json:\"active_env\"`\n\tStandbyEnv Environment `json:\"standby_env\"`\n\tActiveVer  int         `json:\"active_version\"`\n\tStandbyVer int         `json:\"standby_version\"`\n}\n```\nBlueGreenState tracks the current blue-green deployment state.\n\n```go\ntype BlueGreenStrategy struct {\n\t// contains filtered or unexported fields\n}\n```\nBlueGreenStrategy implements zero-downtime deployments by swapping between two environments.\n\n```go\nfunc NewBlueGreenStrategy(logger *slog.Logger) *BlueGreenStrategy\n```\nNewBlueGreenStrategy creates a new BlueGreenStrategy.\n\n```go\nfunc (s *BlueGreenStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)\n```\nExecute performs a blue-green deployment: deploy to standby, health check, then switch traffic.\n\n```go\nfunc (s *BlueGreenStrategy) GetState(workflowID string) (*BlueGreenState, bool)\n```\nGetState returns the current blue-green state for a workflow.\n\n```go\nfunc (s *BlueGreenStrategy) Name() string\n```\nName returns the strategy identifier.\n\n```go\nfunc (s *BlueGreenStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)\n```\nRollback switches traffic back to the previous environment.\n\n```go\nfunc (s *BlueGreenStrategy) Validate(config map[string]any) error\n```\nValidate checks the blue-green configuration.\n\n```go\ntype CanaryConfig struct {\n\tInitialPercent float64       `json:\"initial_percent\"` // default 10\n\tIncrement      float64       `json:\"increment\"`       // default 20\n\tInterval       time.Duration `json:\"interval\"`        // default 30s\n\tErrorThreshold float64       `json:\"error_threshold\"` // default 5 (percent)\n}\n```\nCanaryConfig holds the tunable parameters for canary deployments.\n\n```go\nfunc DefaultCanaryConfig() CanaryConfig\n```\nDefaultCanaryConfig returns the default canary configuration.\n\n```go\ntype CanaryStrategy struct {\n\t// contains filtered or unexported fields\n}\n```\nCanaryStrategy implements gradual traffic-shifting deployments.\n\n```go\nfunc NewCanaryStrategy(logger *slog.Logger) *CanaryStrategy\n```\nNewCanaryStrategy creates a new CanaryStrategy.\n\n```go\nfunc (s *CanaryStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)\n```\nExecute performs a canary deployment with gradual traffic shifting.\n\n```go\nfunc (s *CanaryStrategy) GetSplit(workflowID string) (*TrafficSplit, bool)\n```\nGetSplit returns the current traffic split for a workflow.\n\n```go\nfunc (s *CanaryStrategy) Name() string\n```\nName returns the strategy identifier.\n\n```go\nfunc (s *CanaryStrategy) Rollback(ctx context.Context, workflowID string) (*DeploymentResult, error)\n```\nRollback immediately shifts all traffic back to the stable version.\n\n```go\nfunc (s *CanaryStrategy) SetHealthCheck(fn func(ctx context.Context, workflowID string, version int) (float64, error))\n```\nSetHealthCheck sets a custom health check function for canary evaluation.\n\n```go\nfunc (s *CanaryStrategy) Validate(config map[string]any) error\n```\nValidate checks the canary-specific configuration.\n\n```go\ntype Capabilities struct {\n\tAdd  []string `json:\"add,omitempty\"`\n\tDrop []string `json:\"drop,omitempty\"`\n}\n```\nCapabilities describes Linux capabilities to add or drop.\n\n```go\ntype ComposeSidecarSpec struct {\n\tImage       string            `json:\"image\"`\n\tCommand     string            `json:\"command,omitempty\"`\n\tEnvironment map[string]string `json:\"environment,omitempty\"`\n\tPorts       []string          `json:\"ports,omitempty\"`\n\tVolumes     []string          `json:\"volumes,omitempty\"`\n\tDependsOn   []string          `json:\"dependsOn,omitempty\"`\n}\n```\nComposeSidecarSpec contains Docker Compose-specific sidecar configuration.\n\n```go\ntype DeployArtifacts struct {\n\t// Target is the deploy target name that generated these artifacts.\n\tTarget string `json:\"target\"`\n\t// AppName is the application name.\n\tAppName string `json:\"appName\"`\n\t// Namespace is the target namespace/environment.\n\tNamespace string `json:\"namespace\"`\n\t// Files maps relative file paths to their content.\n\tFiles map[string][]byte `json:\"files,omitempty\"`\n\t// Objects holds structured deployment objects (e.g., k8s unstructured objects).\n\tObjects []any `json:\"-\"`\n\t// Metadata holds target-specific metadata.\n\tMetadata map[string]string `json:\"metadata,omitempty\"`\n}\n```\nDeployArtifacts holds the generated deployment artifacts.\n\n```go\ntype DeployRequest struct {\n\tConfig    *config.WorkflowConfig\n\tManifest  *manifest.WorkflowManifest\n\tSidecars  []*SidecarSpec\n\tImage     string\n\tNamespace string\n\tAppName   string\n\tReplicas  int\n\tExtraEnv  map[string]string\n\tSecretRef string\n\tOutputDir string\n\n\t// Command overrides the container entrypoint.\n\tCommand []string\n\t// Args overrides the default container arguments.\n\tArgs []string\n\t// ImagePullPolicy sets the container image pull policy (\"Never\", \"Always\", \"IfNotPresent\").\n\tImagePullPolicy string\n\t// Strategy sets the deployment strategy (\"Recreate\" or \"RollingUpdate\").\n\tStrategy string\n\t// ServiceAccount sets the pod service account name.\n\tServiceAccount string\n\t// HealthPath overrides the default health check path (\"/healthz\").\n\tHealthPath string\n\t// ConfigMapName overrides the configmap name (default: AppName).\n\tConfigMapName string\n\t// RunAsUser sets the pod security context runAsUser.\n\tRunAsUser *int64\n\t// RunAsNonRoot sets the pod security context runAsNonRoot.\n\tRunAsNonRoot *bool\n\t// FSGroup sets the pod security context fsGroup.\n\tFSGroup *int64\n\t// ConfigFileData is raw config YAML bytes (with env vars expanded).\n\t// If set, used for ConfigMap instead of marshaling Config.\n\tConfigFileData []byte\n}\n```\nDeployRequest bundles everything a DeployTarget needs to generate or apply.\n\n```go\ntype DeployResult struct {\n\t// Status is the deployment status (\"success\", \"failed\", \"in_progress\").\n\tStatus string `json:\"status\"`\n\t// Message is a human-readable description of the result.\n\tMessage string `json:\"message\"`\n\t// StartedAt is when the deployment started.\n\tStartedAt time.Time `json:\"startedAt\"`\n\t// CompletedAt is when the deployment finished.\n\tCompletedAt time.Time `json:\"completedAt\"`\n\t// Resources lists the resources that were created or updated.\n\tResources []DeployedResource `json:\"resources,omitempty\"`\n}\n```\nDeployResult captures the outcome of a deploy apply operation.\n\n```go\ntype DeployStatus struct {\n\t// AppName is the application name.\n\tAppName string `json:\"appName\"`\n\t// Namespace is the deployment namespace.\n\tNamespace string `json:\"namespace\"`\n\t// Phase is the overall deployment phase (\"Running\", \"Pending\", \"Failed\", \"Unknown\").\n\tPhase string `json:\"phase\"`\n\t// Ready is the number of ready replicas.\n\tReady int `json:\"ready\"`\n\t// Desired is the desired number of replicas.\n\tDesired int `json:\"desired\"`\n\t// Message is additional status information.\n\tMessage string `json:\"message,omitempty\"`\n\t// Resources lists individual resource statuses.\n\tResources []ResourceStatus `json:\"resources,omitempty\"`\n}\n```\nDeployStatus represents the current state of a deployment.\n\n```go\ntype DeployTarget interface {\n\t// Name returns the target identifier (e.g., \"kubernetes\", \"ecs\", \"docker-compose\").\n\tName() string\n\n\t// Generate produces platform-specific deployment artifacts from config.\n\tGenerate(ctx context.Context, req *DeployRequest) (*DeployArtifacts, error)\n\n\t// Apply deploys artifacts to the target platform.\n\tApply(ctx context.Context, artifacts *DeployArtifacts, opts ApplyOpts) (*DeployResult, error)\n\n\t// Destroy tears down all resources for the given app.\n\tDestroy(ctx context.Context, appName, namespace string) error\n\n\t// Status returns current deployment status.\n\tStatus(ctx context.Context, appName, namespace string) (*DeployStatus, error)\n\n\t// Diff compares generated artifacts against live state.\n\tDiff(ctx context.Context, artifacts *DeployArtifacts) (string, error)\n\n\t// Logs streams logs from the deployed app.\n\tLogs(ctx context.Context, appName, namespace string, opts LogOpts) (io.ReadCloser, error)\n}\n```\nDeployTarget is the interface that platform-specific deployers implement. Each target (kubernetes, ecs, docker-compose) provides Generate, Apply, Destroy, Status, Diff, and Logs operations.\n\n```go\ntype DeployTargetRegistry struct {\n\t// contains filtered or unexported fields\n}\n```\nDeployTargetRegistry holds registered deploy targets.\n\n```go\nfunc NewDeployTargetRegistry() *DeployTargetRegistry\n```\nNewDeployTargetRegistry creates an empty deploy target registry.\n\n```go\nfunc (r *DeployTargetRegistry) Generate(ctx context.Context, targetName string, req *DeployRequest) (*DeployArtifacts, error)\n```\nGenerate is a convenience method that looks up a target and generates artifacts.\n\n```go\nfunc (r *DeployTargetRegistry) Get(name string) (DeployTarget, bool)\n```\nGet returns the deploy target with the given name.\n\n```go\nfunc (r *DeployTargetRegistry) List() []string\n```\nList returns sorted names of all registered deploy targets.\n\n```go\nfunc (r *DeployTargetRegistry) Register(t DeployTarget)\n```\nRegister adds a deploy target to the registry.\n\n```go\ntype DeployedResource struct {\n\tKind      string `json:\"kind\"`\n\tName      string `json:\"name\"`\n\tNamespace string `json:\"namespace,omitempty\"`\n\tStatus    string `json:\"status\"`\n}\n```\nDeployedResource describes a single deployed resource.\n\n```go\ntype DeploymentPlan struct {\n\tWorkflowID  string         `json:\"workflow_id\"`\n\tFromVersion int            `json:\"from_version\"`\n\tToVersion   int            `json:\"to_version\"`\n\tStrategy    string         `json:\"strategy\"` // \"rolling\", \"blue-green\", \"canary\"\n\tConfig      map[string]any `json:\"config\"`\n}\n```\nDeploymentPlan describes a deployment to execute.\n\n```go\ntype DeploymentResult struct {\n\tStatus      string    `json:\"status\"` // \"success\", \"failed\", \"rolled_back\"\n\tStartedAt   time.Time `json:\"started_at\"`\n\tCompletedAt time.Time `json:\"completed_at\"`\n\tMessage     string    `json:\"message\"`\n\tRolledBack  bool      `json:\"rolled_back\"`\n}\n```\nDeploymentResult captures the outcome of a deployment.\n\n```go\ntype DeploymentStrategy interface {\n\t// Name returns the strategy identifier (e.g., \"rolling\", \"blue-green\", \"canary\").\n\tName() string\n\n\t// Validate checks the strategy-specific configuration.\n\tValidate(config map[string]any) error\n\n\t// Execute runs the deployment according to the plan.\n\tExecute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)\n}\n```\nDeploymentStrategy defines the interface for workflow deployment strategies.\n\n```go\ntype ECSSidecarSpec struct {\n\tImage        string            `json:\"image\"`\n\tCommand      []string          `json:\"command,omitempty\"`\n\tEnv          map[string]string `json:\"env,omitempty\"`\n\tEssential    bool              `json:\"essential\"`\n\tPortMappings []int32           `json:\"portMappings,omitempty\"`\n}\n```\nECSSidecarSpec contains ECS-specific sidecar configuration.\n\n```go\ntype Environment string\n```\nEnvironment identifies a blue-green deployment slot.\n\n```go\nconst (\n\tEnvBlue  Environment = \"blue\"\n\tEnvGreen Environment = \"green\"\n)\n```\n\n```go\ntype K8sSidecarSpec struct {\n\tImage              string            `json:\"image\"`\n\tCommand            []string          `json:\"command,omitempty\"`\n\tArgs               []string          `json:\"args,omitempty\"`\n\tEnv                map[string]string `json:\"env,omitempty\"`\n\tSecretEnv          []SecretEnvVar    `json:\"secretEnv,omitempty\"`\n\tPorts              []int32           `json:\"ports,omitempty\"`\n\tVolumeMounts       []VolumeMount     `json:\"volumeMounts,omitempty\"`\n\tVolumes            []Volume          `json:\"volumes,omitempty\"`\n\tConfigMapData      map[string]string `json:\"configMapData,omitempty\"`\n\tServiceAccountName string            `json:\"serviceAccountName,omitempty\"`\n\tRequiredSecrets    []string          `json:\"requiredSecrets,omitempty\"`\n\tSecurityContext    *SecurityContext  `json:\"securityContext,omitempty\"`\n\tImagePullPolicy    string            `json:\"imagePullPolicy,omitempty\"`\n}\n```\nK8sSidecarSpec contains Kubernetes-specific sidecar configuration.\n\n```go\ntype LogOpts struct {\n\t// Container filters logs to a specific container name.\n\tContainer string `json:\"container,omitempty\"`\n\t// Follow streams logs as they are produced.\n\tFollow bool `json:\"follow,omitempty\"`\n\t// TailLines limits output to the last N lines.\n\tTailLines int64 `json:\"tailLines,omitempty\"`\n\t// Since only shows logs newer than this duration.\n\tSince time.Duration `json:\"since,omitempty\"`\n\t// Previous shows logs from previous container instances.\n\tPrevious bool `json:\"previous,omitempty\"`\n}\n```\nLogOpts configures how Logs behaves.\n\n```go\ntype ResourceStatus struct {\n\tKind      string `json:\"kind\"`\n\tName      string `json:\"name\"`\n\tNamespace string `json:\"namespace,omitempty\"`\n\tStatus    string `json:\"status\"`\n\tMessage   string `json:\"message,omitempty\"`\n}\n```\nResourceStatus describes the status of an individual deployed resource.\n\n```go\ntype RollingConfig struct {\n\tBatchSize int           `json:\"batch_size\"` // default 1\n\tDelay     time.Duration `json:\"delay\"`      // default 5s\n}\n```\nRollingConfig holds the tunable parameters for rolling deployments.\n\n```go\nfunc DefaultRollingConfig() RollingConfig\n```\nDefaultRollingConfig returns the default rolling configuration.\n\n```go\ntype RollingStrategy struct {\n\t// contains filtered or unexported fields\n}\n```\nRollingStrategy implements simple rolling update deployments, updating instances one batch at a time.\n\n```go\nfunc NewRollingStrategy(logger *slog.Logger) *RollingStrategy\n```\nNewRollingStrategy creates a new RollingStrategy.\n\n```go\nfunc (s *RollingStrategy) Execute(ctx context.Context, plan *DeploymentPlan) (*DeploymentResult, error)\n```\nExecute performs a rolling deployment, processing instances in batches.\n\n```go\nfunc (s *RollingStrategy) Name() string\n```\nName returns the strategy identifier.\n\n```go\nfunc (s *RollingStrategy) Validate(config map[string]any) error\n```\nValidate checks the rolling-specific configuration.\n\n```go\ntype SecretEnvVar struct {\n\tEnvName    string `json:\"envName\"`\n\tSecretName string `json:\"secretName\"`\n\tSecretKey  string `json:\"secretKey\"`\n}\n```\nSecretEnvVar describes an environment variable sourced from a Kubernetes secret.\n\n```go\ntype SecurityContext struct {\n\tRunAsUser    *int64        `json:\"runAsUser,omitempty\"`\n\tRunAsGroup   *int64        `json:\"runAsGroup,omitempty\"`\n\tPrivileged   *bool         `json:\"privileged,omitempty\"`\n\tCapabilities *Capabilities `json:\"capabilities,omitempty\"`\n}\n```\nSecurityContext holds security settings for a sidecar container.\n\n```go\ntype SidecarProvider interface {\n\t// Type returns the sidecar type string (e.g., \"sidecar.tailscale\").\n\tType() string\n\n\t// Validate checks the sidecar configuration.\n\tValidate(cfg config.SidecarConfig) error\n\n\t// Resolve produces a platform-specific SidecarSpec from config.\n\tResolve(cfg config.SidecarConfig, platform string) (*SidecarSpec, error)\n}\n```\nSidecarProvider translates platform-agnostic SidecarConfig into platform-specific container specs.\n\n```go\ntype SidecarRegistry struct {\n\t// contains filtered or unexported fields\n}\n```\nSidecarRegistry holds registered sidecar providers.\n\n```go\nfunc NewSidecarRegistry() *SidecarRegistry\n```\nNewSidecarRegistry creates an empty sidecar provider registry.\n\n```go\nfunc (r *SidecarRegistry) Get(typeName string) (SidecarProvider, bool)\n```\nGet returns the sidecar provider for the given type.\n\n```go\nfunc (r *SidecarRegistry) Register(p SidecarProvider)\n```\nRegister adds a sidecar provider to the registry.\n\n```go\nfunc (r *SidecarRegistry) Resolve(sidecars []config.SidecarConfig, platform string) ([]*SidecarSpec, error)\n```\nResolve resolves all sidecar configs into platform-specific specs.\n\n```go\ntype SidecarSpec struct {\n\tName    string\n\tK8s     *K8sSidecarSpec     `json:\"k8s,omitempty\"`\n\tECS     *ECSSidecarSpec     `json:\"ecs,omitempty\"`\n\tCompose *ComposeSidecarSpec `json:\"compose,omitempty\"`\n}\n```\nSidecarSpec is the resolved, platform-specific sidecar output.\n\n```go\ntype StrategyRegistry struct {\n\t// contains filtered or unexported fields\n}\n```\nStrategyRegistry holds the available deployment strategies.\n\n```go\nfunc NewStrategyRegistry(logger *slog.Logger) *StrategyRegistry\n```\nNewStrategyRegistry creates a registry pre-loaded with built-in strategies.\n\n```go\nfunc (r *StrategyRegistry) Execute(plan *DeploymentPlan) (*DeploymentResult, error)\n```\nExecute is a convenience method that looks up a strategy and executes a plan.\n\n```go\nfunc (r *StrategyRegistry) Get(name string) (DeploymentStrategy, bool)\n```\nGet returns the strategy with the given name, or false if not found.\n\n```go\nfunc (r *StrategyRegistry) List() []string\n```\nList returns the sorted names of all registered strategies.\n\n```go\nfunc (r *StrategyRegistry) Register(s DeploymentStrategy)\n```\nRegister adds a strategy to the registry, replacing any existing one with the same name.\n\n```go\ntype TrafficSplit struct {\n\tCanaryPercent float64 `json:\"canary_percent\"`\n\tStablePercent float64 `json:\"stable_percent\"`\n\tCanaryVersion int     `json:\"canary_version\"`\n\tStableVersion int     `json:\"stable_version\"`\n}\n```\nTrafficSplit tracks how traffic is distributed between versions.\n\n```go\ntype Volume struct {\n\tName      string `json:\"name\"`\n\tEmptyDir  bool   `json:\"emptyDir,omitempty\"`\n\tSecret    string `json:\"secret,omitempty\"` //nolint:gosec // G117 — k8s secret name reference, not a secret value\n\tConfigMap string `json:\"configMap,omitempty\"`\n}\n```\nVolume describes a volume for a sidecar container.\n\n```go\ntype VolumeMount struct {\n\tName      string `json:\"name\"`\n\tMountPath string `json:\"mountPath\"`\n\tReadOnly  bool   `json:\"readOnly,omitempty\"`\n}\n```\nVolumeMount describes a volume mount for a sidecar container.\n\n","path":"github.com/GoCodeAlone/workflow/deploy","name":"deploy","synopsis":"","isRedistributable":true}
