release

package
v0.8.8 Latest Latest
Warning

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

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

Documentation

Overview

Package release writes the shadow copy of ADR 050 release snapshots and environment bindings. Nothing here is read by a deploy decision.

Index

Constants

View Source
const (
	ReasonPromote  = "promote"
	ReasonRollback = "rollback"
	ReasonRevert   = "revert"
	ReasonDeploy   = "deploy"
)

Binding change reasons written to binding history.

View Source
const EnvBindings = "APP_RELEASE_BINDINGS"

EnvBindings selects the rollout mode: off (default), shadow or on.

Variables

This section is empty.

Functions

func ImageRef

func ImageRef(image, digest string) string

ImageRef pins a tag reference to its digest, replacing any existing tag.

func Install

func Install(db *store.DB, mode Mode, logger *slog.Logger)

Install hooks the writer onto db. Off mode installs nothing.

func OwnsRelease

func OwnsRelease(ctx context.Context, b Binder, app string, rel *store.Release) bool

OwnsRelease reports whether rel may be applied to app: it was minted from app, or app's binding history has named it.

func PromotionRelease

func PromotionRelease(ctx context.Context, b Binder, source string, logger *slog.Logger) *store.Release

PromotionRelease returns the release source is bound to, or nil when it has none (the tag path then applies, as the ADR's no-digest fallback).

func Retarget

func Retarget(ctx context.Context, b Binder, audit Auditor, logger *slog.Logger, target store.DesiredService, releaseID, reason, by, approvalID string) (func(), error)

Retarget points target's binding at releaseID, audits the move and returns an undo for the caller to run if the deploy then fails, so the binding never names a release that did not run. The undo only applies while the binding still names releaseID, so a newer retarget is never reverted.

func RollbackReleaseID

func RollbackReleaseID(ctx context.Context, b Binder, target store.DeployAttempt) string

RollbackReleaseID finds the release a past attempt ran: the one minted from it, else a bound release of the app with the same digest pinned ref.

Types

type Auditor

type Auditor func(ctx context.Context, actor, action, detail string)

Auditor records one platform-initiated event.

func AuditorFor

func AuditorFor(db *store.DB, logger *slog.Logger) Auditor

AuditorFor writes system audit rows straight to the store, for callers that have no API router.

type Binder

type Binder interface {
	GetRelease(ctx context.Context, id string) (*store.Release, error)
	GetReleaseByAttempt(ctx context.Context, attemptID string) (*store.Release, error)
	GetEnvironmentBinding(ctx context.Context, app string) (*store.EnvironmentBinding, error)
	ListBindingHistory(ctx context.Context, app string) ([]store.BindingHistoryEntry, error)
	RetargetBinding(ctx context.Context, app, environmentID, releaseID, reason, by, approvalID string) (bool, error)
	RetargetBindingIf(ctx context.Context, app, environmentID, releaseID, expected, reason, by, approvalID string) (bool, error)
	UnbindRelease(ctx context.Context, app, expected, by string) (bool, error)
}

Binder is the store surface that makes bindings authoritative. It lives here so the API and the pipeline runner retarget through one code path.

type Config

type Config struct {
	Health    *store.ServiceHealth    `json:"health,omitempty"`
	Replicas  int                     `json:"replicas,omitempty"`
	Strategy  string                  `json:"strategy,omitempty"`
	Resources *store.ServiceResources `json:"resources,omitempty"`
	Labels    map[string]string       `json:"labels,omitempty"`
}

Config is the environment neutral subset of a deploy snapshot. It holds no env values, domains, ports, volumes or placement.

type Mode

type Mode string

Mode is the parsed APP_RELEASE_BINDINGS value.

const (
	ModeOff    Mode = "off"
	ModeShadow Mode = "shadow"
	ModeOn     Mode = "on"
)

Rollout modes. Only off, the default, leaves the store untouched.

func ModeFromEnv

func ModeFromEnv() Mode

ModeFromEnv reads the flag; unknown values count as off.

func (Mode) Authoritative

func (m Mode) Authoritative() bool

Authoritative reports whether promote and rollback decide through bindings.

func (Mode) Writes

func (m Mode) Writes() bool

Writes reports whether the mode records release rows. On also makes the binding authoritative for promote and rollback (see Mode.Authoritative).

type Shadow

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

Shadow records releases and bindings next to the existing deploy path.

func NewShadow

func NewShadow(db *store.DB, mode Mode, logger *slog.Logger) *Shadow

NewShadow builds a writer for mode.

func (*Shadow) OnAttempt

func (s *Shadow) OnAttempt(ctx context.Context, attemptID string)

OnAttempt is the store hook. A failure only logs a warning, never the deploy.

func (*Shadow) Record

func (s *Shadow) Record(ctx context.Context, attemptID string) error

Record mints the release for a succeeded attempt that has a digest, then notes the binding it would imply. Anything else is a quiet no-op.

Jump to

Keyboard shortcuts

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