deploy

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package deploy runs the build+release pipeline: fetch → build → run new → health-gate → retire old. One FIFO worker; logs persist to disk and fan out live via the stream hub on topic "deploy:<id>".

Index

Constants

View Source
const DeployKind = "tile.deploy"

DeployKind is the work-queue kind one deploy runs under.

View Source
const WaitingPrefix = "waiting:"

WaitingPrefix marks a tile parked on a value its config declares and nobody has set. The status column carries the name so the canvas can say which one without a second query per card.

Variables

This section is empty.

Functions

func BuilderFor

func BuilderFor(orgSlug string) string

BuilderFor is the buildx builder an org's builds run in on the manager.

func ClearWaiting

func ClearWaiting(ctx context.Context, store repo.Store, name string, stackIDs ...string)

ClearWaiting releases every tile of the given stacks parked on name, now that somebody has set it. The tile goes to "stopped", which is what it actually is: nothing is running and the canvas offers Deploy. Deploying for them would be a surprise: setting a variable is not a request to ship.

Scoped to stacks because a variable name is not unique across tenants; one org setting DATABASE_URL must not touch another org's cards.

func ClearWaitingEnv

func ClearWaitingEnv(ctx context.Context, store repo.Store, envID, name string)

ClearWaitingEnv releases only the tiles of one environment. An env-scoped value satisfies nothing outside its env: the other envs are still parked on the same name and have to keep saying so.

func ClearWaitingOrg

func ClearWaitingOrg(ctx context.Context, store repo.Store, orgID, name string)

ClearWaitingOrg is ClearWaiting over every stack in an org, for org-scoped variables.

func DepWaiting

func DepWaiting(ctx context.Context, store repo.Store, app *repo.Tile) error

DepWaiting reports whether any of the tile's dependencies is itself parked on a value, as the same UnsetError an unresolved reference produces, so the caller's existing waiting branch parks this tile on the same name. Setting the value then releases the whole chain at once, because ClearWaiting matches on the name and nothing else.

Without it a dependent either goes red after the two-minute depends_on wait (:healthy, :completed) or starts blind against a tile that never came up (:started). Neither is the truth: it is waiting, same as its dependency.

func WaitingFor

func WaitingFor(status string) string

WaitingFor returns the value a tile is parked on, or "" when it is not.

Types

type Engine

type Engine struct {

	// GitAuth optionally returns extra environment lines (GIT_CONFIG_*) that
	// authenticate the tile's fetch/clone (e.g. a GitHub App installation
	// token via its connector). Env rather than argv so tokens stay out of
	// /proc. Set once at startup, before the worker runs.
	GitAuth func(ctx context.Context, tile *repo.Tile) []string
	// RegistryAuth optionally returns docker login credentials for pulling
	// the tile's image (e.g. ghcr.io via its connector). "" = none.
	RegistryAuth func(ctx context.Context, tile *repo.Tile) (user, pass string)
	// OnFinish, if set, is called after a deployment reaches a terminal
	// status (done/error/cancelled).
	OnFinish func(tile *repo.Tile, d *repo.Deployment)
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(store repo.Store, rt *runtime.Runtime, clus *cluster.Cluster, hub *stream.Hub, dataDir string, notifier *notify.Notifier) *Engine

func (*Engine) Cancel

func (e *Engine) Cancel(ctx context.Context, deploymentID string)

func (*Engine) CurrentImage

func (e *Engine) CurrentImage(ctx context.Context, app *repo.Tile) string

CurrentImage is the tag of the tile's newest successful deployment, "" when it has never deployed.

func (*Engine) DeployLog

func (e *Engine) DeployLog(deploymentID string) (string, error)

DeployLog reads a deployment's captured build/deploy log ("" if none yet).

func (*Engine) Enqueue

func (e *Engine) Enqueue(ctx context.Context, app *repo.Tile, trigger string) (string, error)

func (*Engine) EnqueueCurrent

func (e *Engine) EnqueueCurrent(ctx context.Context, app *repo.Tile, trigger string) (string, error)

EnqueueCurrent restarts the tile on the image it already runs, with the given trigger. Config changes on an env above the bottom rung go through here so an apply never ships code nobody promoted. Returns "" and no error when the tile has no image yet; the caller decides what to do then.

func (*Engine) EnqueuePromote

func (e *Engine) EnqueuePromote(ctx context.Context, app *repo.Tile, commitSHA string) (string, error)

EnqueuePromote queues a deployment of the image built at commitSHA: the tag is <repo>:<sha7>, run as is when it exists locally (a lower env built it) and built at that commit when it does not.

func (*Engine) EnqueueRollback

func (e *Engine) EnqueueRollback(ctx context.Context, app *repo.Tile, imageTag string) (string, error)

EnqueueRollback queues a deployment that re-runs a previously built image.

func (*Engine) FailWaiting

func (e *Engine) FailWaiting(ctx context.Context, d *repo.Deployment, msg string)

FailWaiting errors a parked deployment (CI failed, or the gate cannot evaluate it and says why).

func (*Engine) ListBranches

func (e *Engine) ListBranches(ctx context.Context, app *repo.Tile) []string

ListBranches runs `git ls-remote --heads` for an app's repo and returns the branch names. Best-effort: returns nil on any error (bad URL, auth, timeout).

func (*Engine) LogPath

func (e *Engine) LogPath(deploymentID string) string

LogPath returns the on-disk log file for a deployment.

func (*Engine) Park

func (e *Engine) Park(ctx context.Context, app *repo.Tile, trigger, commitSHA string) (string, error)

Park records a push held back by wait_for_ci: a waiting_ci deployment the CI gate releases (or fails) once the commit's checks settle. Parked rows survive restarts, the boot sweep only clears queued/running.

func (*Engine) Release

func (e *Engine) Release(ctx context.Context, d *repo.Deployment) error

Release moves a parked deployment into the build queue.

func (*Engine) RepoDir

func (e *Engine) RepoDir(app *repo.Tile) string

Enqueue creates a deployment for the app and queues it. Returns its ID. RepoDir is where a git tile's clone lives; it exists once the tile has deployed at least once.

func (*Engine) SupersedeWaiting

func (e *Engine) SupersedeWaiting(ctx context.Context, tileID, note string)

SupersedeWaiting cancels a tile's parked waiting_ci deployments.

func (*Engine) WithWork

func (e *Engine) WithWork(q *workqueue.Queue) *Engine

WithWork puts deploys on the durable queue.

Requeue on restart. A deploy is convergent in the way that matters here: it re-reads the deployment row, re-fetches or re-pulls, and rolls the service, so running it again from the top on a half-finished build finishes the job. The dedupe key is the tile, which is exactly what SupersedeWaiting does by hand: a newer deploy of the same tile outranks one still waiting.

Jump to

Keyboard shortcuts

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