stackcmd

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package stackcmd is the behaviour behind the host-side verbs — install/converge, upgrade, restart, status and uninstall — with no command-line framework attached.

Two front-ends drive it, and they must not drift:

  • `miabi setup|upgrade|stack …` in the CLI (cobra), the normal path;
  • `docker run miabi/miabi:<tag> install …` on the server image (okapicli), which is how a user without root installs — the image runs as uid 10001 with the host's docker group, so nothing has to be written to /usr/local/bin.

Each front-end owns only its flag parsing and its rendering; everything that decides what happens to a host lives here, once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Restart

func Restart(ctx context.Context, svc *stack.Service, path, component string, yes bool, ui UI) error

Restart restarts containers WITHOUT recreating them, so they re-read what is on disk. Editing the gateway's goma.yml is the obvious case (Goma watches its providers directory, not its base config); a spec change is the obvious non-case, and Service.Restart says so.

func Uninstall

func Uninstall(ctx context.Context, svc *stack.Service, path string, withVolumes, yes bool, ui UI, removeFile func(string) error) error

Uninstall removes the stack's containers. Volumes are kept unless withVolumes, in which case the manifest goes too — it describes an install that no longer exists.

func Upgrade

func Upgrade(ctx context.Context, svc *stack.Service, path string, o UpgradeOptions, ui UI) error

Upgrade rolls a component to a newer image, rolling back automatically if the new one never becomes healthy. With no component named it moves the control plane and re-converges the rest.

func WithInstallHint

func WithInstallHint(err error) error

WithInstallHint turns "no manifest" into an answer rather than a dead end. The same error means very different things depending on whether Miabi is running.

Types

type SetupOptions

type SetupOptions struct {
	Domain, AdminEmail, ACMEEmail, ControlURL    string
	Image, GatewayImage, RunnerImage, GomaConfig string
	RegistryHost, Subnet                         string
	Registry, NoHostProc, Yes                    bool

	// DefaultImage supplies the control-plane image for a FRESH install when Image is empty. The
	// two front-ends answer this differently and neither answer generalizes: the server image
	// inspects the container it is running in (so `docker run miabi/miabi:1.8.0 install` lands
	// exactly 1.8.0, private registry included), while the CLI has no self-container and uses its
	// build stamp. Return "" when it cannot be determined.
	DefaultImage func() string
}

SetupOptions is the flag surface of install/setup, already parsed.

type SetupResult

type SetupResult struct {
	Manifest *stack.Manifest
	Path     string
	// NewInstall is false for a converge of an existing manifest.
	NewInstall bool
}

SetupResult reports what a Setup did, so the caller can print its own next-steps hint — the one piece of the output that legitimately differs between the two front-ends.

func Setup

func Setup(ctx context.Context, svc *stack.Service, path string, o SetupOptions, ui UI) (*SetupResult, error)

Setup installs the stack, or converges an existing install to its manifest. It is idempotent: run against an existing manifest it keeps the stored secrets, because a regenerated database password would lock the new control plane out of its own data.

type StatusReport

type StatusReport struct {
	Manifest *stack.Manifest
	Path     string
	Found    []stack.Component
	// LegacyConfig is set when the manifest is at the pre-rename path. The host IS installed —
	// saying otherwise sends its operator hunting for a Compose stack that never existed.
	LegacyConfig error
	// Unmanaged is set when containers exist but no manifest does: a Compose or hand-rolled install.
	Unmanaged bool
	// Drift lists components running an image the manifest does not pin.
	Drift []string
}

StatusReport is what status found. The caller renders it: the two front-ends draw different tables, but neither decides what is in one.

func Status

func Status(ctx context.Context, svc *stack.Service, path string) (*StatusReport, error)

Status discovers the running stack and compares it against the manifest.

type UI

type UI interface {
	Printf(format string, a ...any)
	Info(format string, a ...any)
	Success(format string, a ...any)
	Warn(format string, a ...any)
	// Confirm asks a yes/no question. It is never called when the caller passed Yes.
	Confirm(prompt string) bool
}

UI is the front-end's output. The CLI colors it; the server image prints plainly.

type UpgradeOptions

type UpgradeOptions struct {
	// Component is empty for the whole stack, else one component by name.
	Component string
	Image     string
	Version   string
	Yes       bool
	// DefaultImage is as in SetupOptions.
	DefaultImage func() string
}

UpgradeOptions is the flag surface of upgrade/update, already parsed.

Jump to

Keyboard shortcuts

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