deploy

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package deploy defines the deployment and release domain entities, the deployment service interface, strategy abstraction, and persistence store for tracking deployments and immutable release snapshots.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewService

func NewService(
	store Store,
	instStore instance.Store,
	providers *provider.Registry,
	events event.Bus,
	authProvider auth.Provider,
) *service

NewService creates a deploy service with the given dependencies.

Types

type DeployListResult

type DeployListResult struct {
	Items      []*Deployment `json:"items"`
	NextCursor string        `json:"next_cursor,omitempty"`
	Total      int           `json:"total"`
}

DeployListResult holds a page of deployments with cursor-based pagination.

type DeployRequest

type DeployRequest struct {
	InstanceID id.ID             `json:"instance_id"          validate:"required"`
	Image      string            `json:"image"                validate:"required"`
	Env        map[string]string `json:"env,omitempty"`
	Strategy   string            `json:"strategy,omitempty"`
	Notes      string            `json:"notes,omitempty"`
	CommitSHA  string            `json:"commit_sha,omitempty"`
}

DeployRequest holds the parameters for initiating a deployment.

type DeployState

type DeployState string

DeployState represents the lifecycle state of a deployment.

const (
	// DeployPending indicates the deployment is queued.
	DeployPending DeployState = "pending"

	// DeployRunning indicates the deployment is in progress.
	DeployRunning DeployState = "running"

	// DeploySucceeded indicates the deployment completed successfully.
	DeploySucceeded DeployState = "succeeded"

	// DeployFailed indicates the deployment failed.
	DeployFailed DeployState = "failed"

	// DeployRolledBack indicates the deployment was rolled back.
	DeployRolledBack DeployState = "rolled_back"

	// DeployCancelled indicates the deployment was cancelled.
	DeployCancelled DeployState = "cancelled"
)

type Deployment

type Deployment struct {
	ctrlplane.Entity

	TenantID    string            `db:"tenant_id"    json:"tenant_id"`
	InstanceID  id.ID             `db:"instance_id"  json:"instance_id"`
	ReleaseID   id.ID             `db:"release_id"   json:"release_id"`
	State       DeployState       `db:"state"        json:"state"`
	Strategy    string            `db:"strategy"     json:"strategy"`
	Image       string            `db:"image"        json:"image"`
	Env         map[string]string `db:"env"          json:"env,omitempty"`
	ProviderRef string            `db:"provider_ref" json:"provider_ref,omitempty"`
	StartedAt   *time.Time        `db:"started_at"   json:"started_at,omitempty"`
	FinishedAt  *time.Time        `db:"finished_at"  json:"finished_at,omitempty"`
	Error       string            `db:"error"        json:"error,omitempty"`
	Initiator   string            `db:"initiator"    json:"initiator"`
}

Deployment tracks a single deploy operation for an instance.

type ListOptions

type ListOptions struct {
	Cursor string `json:"cursor,omitempty"`
	Limit  int    `json:"limit,omitempty"`
}

ListOptions configures deployment or release listing with pagination.

type Release

type Release struct {
	ctrlplane.Entity

	TenantID   string            `db:"tenant_id"   json:"tenant_id"`
	InstanceID id.ID             `db:"instance_id" json:"instance_id"`
	Version    int               `db:"version"     json:"version"`
	Image      string            `db:"image"       json:"image"`
	Env        map[string]string `db:"env"         json:"env,omitempty"`
	Notes      string            `db:"notes"       json:"notes,omitempty"`
	CommitSHA  string            `db:"commit_sha"  json:"commit_sha,omitempty"`
	Active     bool              `db:"active"      json:"active"`
}

Release is an immutable snapshot of an application version.

type ReleaseListResult

type ReleaseListResult struct {
	Items      []*Release `json:"items"`
	NextCursor string     `json:"next_cursor,omitempty"`
	Total      int        `json:"total"`
}

ReleaseListResult holds a page of releases with cursor-based pagination.

type Service

type Service interface {
	// Deploy creates a new release and deploys it to the instance.
	Deploy(ctx context.Context, req DeployRequest) (*Deployment, error)

	// Rollback reverts to a specific release.
	Rollback(ctx context.Context, instanceID id.ID, releaseID id.ID) (*Deployment, error)

	// Cancel aborts an in-progress deployment.
	Cancel(ctx context.Context, deploymentID id.ID) error

	// GetDeployment returns a specific deployment.
	GetDeployment(ctx context.Context, deploymentID id.ID) (*Deployment, error)

	// ListDeployments lists deployments for an instance.
	ListDeployments(ctx context.Context, instanceID id.ID, opts ListOptions) (*DeployListResult, error)

	// GetRelease returns a specific release.
	GetRelease(ctx context.Context, releaseID id.ID) (*Release, error)

	// ListReleases lists releases for an instance.
	ListReleases(ctx context.Context, instanceID id.ID, opts ListOptions) (*ReleaseListResult, error)
}

Service manages deployments and releases for instances.

type Store

type Store interface {
	// InsertDeployment persists a new deployment.
	InsertDeployment(ctx context.Context, d *Deployment) error

	// GetDeployment retrieves a deployment by ID within a tenant.
	GetDeployment(ctx context.Context, tenantID string, deployID id.ID) (*Deployment, error)

	// UpdateDeployment persists changes to an existing deployment.
	UpdateDeployment(ctx context.Context, d *Deployment) error

	// ListDeployments returns a filtered, paginated list of deployments for an instance.
	ListDeployments(ctx context.Context, tenantID string, instanceID id.ID, opts ListOptions) (*DeployListResult, error)

	// InsertRelease persists a new release.
	InsertRelease(ctx context.Context, r *Release) error

	// GetRelease retrieves a release by ID within a tenant.
	GetRelease(ctx context.Context, tenantID string, releaseID id.ID) (*Release, error)

	// ListReleases returns a filtered, paginated list of releases for an instance.
	ListReleases(ctx context.Context, tenantID string, instanceID id.ID, opts ListOptions) (*ReleaseListResult, error)

	// NextReleaseVersion returns the next auto-incrementing version number for an instance.
	NextReleaseVersion(ctx context.Context, tenantID string, instanceID id.ID) (int, error)
}

Store is the persistence interface for deployments and releases.

type Strategy

type Strategy interface {
	// Name returns the strategy identifier (e.g., "rolling", "blue-green").
	Name() string

	// Execute performs the deployment according to the strategy.
	Execute(ctx context.Context, params StrategyParams) error
}

Strategy defines how a deployment is executed. Implementations handle the mechanics of rolling, blue-green, canary, etc.

type StrategyParams

type StrategyParams struct {
	Deployment *Deployment
	Provider   provider.Provider
	OnProgress func(phase string, percent int, message string)
}

StrategyParams provides everything a strategy needs to execute a deployment.

Directories

Path Synopsis
Package strategies provides built-in deployment strategy implementations.
Package strategies provides built-in deployment strategy implementations.

Jump to

Keyboard shortcuts

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