promotion

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApprovalStatus

type ApprovalStatus string

ApprovalStatus represents the status of a promotion approval.

const (
	ApprovalPending  ApprovalStatus = "pending"
	ApprovalApproved ApprovalStatus = "approved"
	ApprovalRejected ApprovalStatus = "rejected"
)

type DeployFunc

type DeployFunc func(ctx context.Context, env EnvironmentName, workflowName, configYAML string) error

DeployFunc deploys a config to a target environment.

type Environment

type Environment struct {
	Name             EnvironmentName `json:"name"`
	Description      string          `json:"description"`
	RequiresApproval bool            `json:"requiresApproval"`
	ValidationRules  []string        `json:"validationRules,omitempty"`
	Order            int             `json:"order"` // lower = earlier in pipeline
}

Environment represents a deployment target.

type EnvironmentName

type EnvironmentName string

EnvironmentName identifies an environment.

const (
	EnvDev     EnvironmentName = "dev"
	EnvStaging EnvironmentName = "staging"
	EnvProd    EnvironmentName = "prod"
)

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler provides HTTP endpoints for multi-environment promotion.

func NewHandler

func NewHandler(pipeline *Pipeline) *Handler

NewHandler creates a new promotion HTTP handler.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers promotion API routes on the given mux.

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

Pipeline manages promotions across environments.

func NewPipeline

func NewPipeline(validateFn ValidateFunc, deployFn DeployFunc) *Pipeline

NewPipeline creates a new promotion pipeline with default environments.

func (*Pipeline) Approve

func (p *Pipeline) Approve(ctx context.Context, promotionID, approvedBy string) (*PromotionRecord, error)

Approve approves a pending promotion and executes it.

func (*Pipeline) Deploy

func (p *Pipeline) Deploy(ctx context.Context, workflowName string, env EnvironmentName, configYAML string) error

Deploy deploys a config directly to an environment (used for dev/staging without promotion).

func (*Pipeline) GetAllConfigs

func (p *Pipeline) GetAllConfigs(workflowName string) map[EnvironmentName]string

GetAllConfigs returns all deployed configs for a workflow across environments.

func (*Pipeline) GetConfig

func (p *Pipeline) GetConfig(workflowName string, env EnvironmentName) (string, bool)

GetConfig returns the currently deployed config for a workflow in an environment.

func (*Pipeline) GetEnvironment

func (p *Pipeline) GetEnvironment(name EnvironmentName) (*Environment, bool)

GetEnvironment returns an environment by name.

func (*Pipeline) GetPromotion

func (p *Pipeline) GetPromotion(id string) (*PromotionRecord, bool)

GetPromotion returns a promotion record by ID.

func (*Pipeline) ListEnvironments

func (p *Pipeline) ListEnvironments() []*Environment

ListEnvironments returns all environments sorted by order.

func (*Pipeline) ListPromotions

func (p *Pipeline) ListPromotions() []*PromotionRecord

ListPromotions returns all promotions sorted newest first.

func (*Pipeline) Promote

func (p *Pipeline) Promote(ctx context.Context, workflowName string, fromEnv, toEnv EnvironmentName, requestedBy string) (*PromotionRecord, error)

Promote initiates a promotion from one environment to another. If the target environment requires approval, the promotion status is set to pending.

func (*Pipeline) Reject

func (p *Pipeline) Reject(promotionID, rejectedBy, reason string) (*PromotionRecord, error)

Reject rejects a pending promotion.

func (*Pipeline) SetEnvironment

func (p *Pipeline) SetEnvironment(env *Environment)

SetEnvironment adds or updates an environment definition.

type PromotionRecord

type PromotionRecord struct {
	ID             string          `json:"id"`
	WorkflowName   string          `json:"workflowName"`
	ConfigYAML     string          `json:"configYaml"`
	FromEnv        EnvironmentName `json:"fromEnv"`
	ToEnv          EnvironmentName `json:"toEnv"`
	Status         PromotionStatus `json:"status"`
	RequestedBy    string          `json:"requestedBy"`
	ApprovalStatus ApprovalStatus  `json:"approvalStatus,omitempty"`
	ApprovedBy     string          `json:"approvedBy,omitempty"`
	ApprovedAt     *time.Time      `json:"approvedAt,omitempty"`
	Error          string          `json:"error,omitempty"`
	CreatedAt      time.Time       `json:"createdAt"`
	CompletedAt    *time.Time      `json:"completedAt,omitempty"`
}

PromotionRecord tracks a single promotion operation.

type PromotionStatus

type PromotionStatus string

PromotionStatus represents the overall status of a promotion.

const (
	PromotionPending  PromotionStatus = "pending_approval"
	PromotionApproved PromotionStatus = "approved"
	PromotionRejected PromotionStatus = "rejected"
	PromotionDeployed PromotionStatus = "deployed"
	PromotionFailed   PromotionStatus = "failed"
)

type ValidateFunc

type ValidateFunc func(ctx context.Context, env EnvironmentName, configYAML string) error

ValidateFunc validates a config for a target environment.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL