Documentation
¶
Overview ¶
Package backend is the orchestrator seam of the Transaction: the port every backend (Portainer API, compose runtimes) implements, reshaped around what one Transaction needs — observe a stack, deploy a compose document, and prove the stack's services are running. Drift comparison stays in the updater core, which is why observation carries a fingerprint rather than the pieces it was computed from.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EngineUnavailable ¶
EngineUnavailable builds an EngineUnavailableError.
func Ineligible ¶
Ineligible builds an IneligibleError.
Types ¶
type ContextPort ¶ added in v1.2.0
ContextPort binds backend operations to a caller lifetime.
type EngineUnavailableError ¶
type EngineUnavailableError struct {
}
EngineUnavailableError marks a backend that could not be reached or spoken to at all — a missing binary, a dead socket, an unusable API. It maps to ResultCode engine_unavailable, never to a stack fault.
func (*EngineUnavailableError) Error ¶
func (e *EngineUnavailableError) Error() string
func (*EngineUnavailableError) Unwrap ¶
func (e *EngineUnavailableError) Unwrap() error
type IneligibleError ¶
type IneligibleError struct {
Reason string
}
IneligibleError marks a stack the Transaction must refuse to act on — a policy/reality mismatch rather than a failure. It maps to ResultCode ineligible.
func (*IneligibleError) Error ¶
func (e *IneligibleError) Error() string
type NotVisibleError ¶
type NotVisibleError struct {
Stack string
}
NotVisibleError marks a stack the policy declares but the backend cannot see — usually a stack the automation identity has no access to. It maps to ResultCode not_visible.
func (*NotVisibleError) Error ¶
func (e *NotVisibleError) Error() string
type Port ¶
type Port interface {
// Preflight proves the backend is reachable and acting as the
// identity the policy expects, before a run does any inventory work.
Preflight() error
// Observe reads the stack's current state through the backend.
Observe(stack config.StackPolicy) (StackState, error)
// RunningDigests re-reads only which digests are running, for the
// repeated checks verification makes.
RunningDigests(state StackState) (map[string]string, error)
// Deploy redeploys the stack with a new Compose document. repull
// asks the engine to re-pull mutable tags; backends that always pin
// digests refuse it.
Deploy(state StackState, compose string, repull bool) error
// ServicesRunning reports whether every configured service of the
// stack is running (and healthy where the engine tracks health),
// with a human-readable detail when it is not. It is the engine-level
// half of verification; the functional health check is the other.
ServicesRunning(state StackState) (bool, string, error)
}
Port is the backend seam. Implementations are the Portainer API adapter and the compose-runtime adapter.
type StackState ¶
type StackState struct {
Backend domain.Backend
// Stack is the policy-declared name, the identity used everywhere.
Stack string
// Compose is the deployed Compose document as text — the bytes an
// apply rewrites and a rollback restores.
Compose string
// Fingerprint covers everything an apply depends on staying still.
// Any change between planning and applying is drift.
Fingerprint string
// Services are the resolved service names, sorted.
Services []string
// ServiceImages is each service's image reference with variable
// interpolation applied — what the engine will actually run.
ServiceImages map[string]string
// DeclaredImages is each service's image reference as literally
// written in the Compose document. It differs from ServiceImages
// only for interpolated lines, which cannot be pinned.
DeclaredImages map[string]string
// RunningDigests maps service name to the digest currently running.
// Nil when the backend cannot prove running digests and only the
// stack-level image status is available.
RunningDigests map[string]string
// ImageStatus is the backend's own "updated"/"outdated" verdict, set
// only when RunningDigests is nil.
ImageStatus string
// GitBacked marks a stack deployed from Git, which is never mutated
// in place — changes go through a Proposal.
GitBacked bool
// Handle carries backend-private identity (a Portainer stack, a
// compose file and project) back into Deploy.
Handle any
}
StackState is one stack as a backend sees it at one instant.