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
- func BuilderFor(orgSlug string) string
- func ClearWaiting(ctx context.Context, store repo.Store, name string, stackIDs ...string)
- func ClearWaitingEnv(ctx context.Context, store repo.Store, envID, name string)
- func ClearWaitingOrg(ctx context.Context, store repo.Store, orgID, name string)
- func DepWaiting(ctx context.Context, store repo.Store, app *repo.Tile) error
- func WaitingFor(status string) string
- type Engine
- func (e *Engine) Cancel(ctx context.Context, deploymentID string)
- func (e *Engine) CurrentImage(ctx context.Context, app *repo.Tile) string
- func (e *Engine) DeployLog(deploymentID string) (string, error)
- func (e *Engine) Enqueue(ctx context.Context, app *repo.Tile, trigger string) (string, error)
- func (e *Engine) EnqueueCurrent(ctx context.Context, app *repo.Tile, trigger string) (string, error)
- func (e *Engine) EnqueuePromote(ctx context.Context, app *repo.Tile, commitSHA string) (string, error)
- func (e *Engine) EnqueueRollback(ctx context.Context, app *repo.Tile, imageTag string) (string, error)
- func (e *Engine) FailWaiting(ctx context.Context, d *repo.Deployment, msg string)
- func (e *Engine) ListBranches(ctx context.Context, app *repo.Tile) []string
- func (e *Engine) LogPath(deploymentID string) string
- func (e *Engine) Park(ctx context.Context, app *repo.Tile, trigger, commitSHA string) (string, error)
- func (e *Engine) Release(ctx context.Context, d *repo.Deployment) error
- func (e *Engine) RepoDir(app *repo.Tile) string
- func (e *Engine) SupersedeWaiting(ctx context.Context, tileID, note string)
- func (e *Engine) WithWork(q *workqueue.Queue) *Engine
Constants ¶
const DeployKind = "tile.deploy"
DeployKind is the work-queue kind one deploy runs under.
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 ¶
BuilderFor is the buildx builder an org's builds run in on the manager.
func ClearWaiting ¶
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 ¶
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 ¶
ClearWaitingOrg is ClearWaiting over every stack in an org, for org-scoped variables.
func DepWaiting ¶
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 ¶
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 (*Engine) CurrentImage ¶
CurrentImage is the tag of the tile's newest successful deployment, "" when it has never deployed.
func (*Engine) DeployLog ¶
DeployLog reads a deployment's captured build/deploy log ("" if none yet).
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 ¶
FailWaiting errors a parked deployment (CI failed, or the gate cannot evaluate it and says why).
func (*Engine) ListBranches ¶
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) 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) RepoDir ¶
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 ¶
SupersedeWaiting cancels a tile's parked waiting_ci deployments.
func (*Engine) WithWork ¶
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.