stackcmd

package
v1.10.25 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: AGPL-3.0, Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package stackcmd holds host-side verb behaviour shared by the cobra CLI and the image's okapicli, so they can't drift.

Index

Constants

View Source
const LabelPreRestore = "pre-restore"

Only these are pruned; a dump the operator asked for is never deleted.

Variables

This section is empty.

Functions

func Apply added in v1.10.14

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

The second half of `env set`, so a batch of edits costs one recreate per component.

func Backup added in v1.10.21

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

Database only: not volumes, certificates or the manifest, whose encryption key the dump needs.

func BackupDir added in v1.10.21

func BackupDir(manifestPath string) string

Beside the manifest, which is already writable and bind-mounted by the containerized installer.

func EnvGet added in v1.10.1

func EnvGet(path, key string, o EnvOptions) (value string, found bool, err error)

found=false should be reported as such rather than printed as an empty line.

func EnvList added in v1.10.1

func EnvList(path string, o EnvOptions) (map[string]string, string, error)

EnvList returns the environment the manifest carries, and the name of the block it came from.

func EnvSet added in v1.10.1

func EnvSet(ctx context.Context, svc *stack.Service, path string, assignments []string, o EnvOptions, ui UI) error

Validation is Normalize's, whose errors name where a refused value really lives.

func EnvUnset added in v1.10.1

func EnvUnset(ctx context.Context, svc *stack.Service, path string, keys []string, o EnvOptions, ui UI) error

A seeded key comes back at its default rather than disappearing, and the caller is told so.

func Restart

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

Restarts without recreating, so on-disk changes like goma.yml are re-read but spec changes are not.

func Restore added in v1.10.21

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

The current database is dumped first, so a restore can itself be undone.

func Uninstall

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

With volumes removed the manifest goes too, since 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

func WithInstallHint

func WithInstallHint(err error) error

Types

type BackupOptions added in v1.10.21

type BackupOptions struct {
	// Dir defaults to BackupDir.
	Dir   string
	Label string
}

BackupOptions is the flag surface of `stack backup`, already parsed.

type DBBackup added in v1.10.21

type DBBackup struct {
	Path    string
	Version string
	Label   string
	Taken   time.Time
	Size    int64
}

DBBackup is one dump found on disk.

func ListBackups added in v1.10.21

func ListBackups(dir string) ([]DBBackup, error)

Files not following the naming scheme are ignored rather than guessed at.

type EnvOptions added in v1.10.1

type EnvOptions struct {
	// Gateway edits the gateway's environment instead of the control plane's.
	Gateway bool
	// Off by default so several edits cost one recreate through Apply.
	Apply bool
	Yes   bool
}

EnvOptions is the flag surface of the env verbs, already parsed.

type RestoreOptions added in v1.10.21

type RestoreOptions struct {
	// File is a path, or the bare name of a dump in BackupDir.
	File string
	Yes  bool
	// Force restores a dump taken by a newer Miabi than the one running.
	Force bool
}

RestoreOptions is the flag surface of `stack restore`, already parsed.

type SetupOptions

type SetupOptions struct {
	Domain, AdminEmail, ACMEEmail, ControlURL    string
	Image, GatewayImage, RunnerImage, GomaConfig string
	RegistryHost, Subnet, InternalSubnet         string
	Registry, NoHostProc, Yes                    bool
	// IPv6 gives the shared app network and every workspace network a dual-stack address space.
	IPv6 bool
	// AdminPassword is the first admin's password; empty generates one. Only a fresh install uses it.
	AdminPassword string
	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
}

func Setup

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

Idempotent: an existing manifest keeps its secrets, since a regenerated DB password locks out the data.

type StatusReport

type StatusReport struct {
	Manifest *stack.Manifest
	Path     string
	Found    []stack.Component
	// The host is installed; saying otherwise sends the operator hunting for a Compose stack.
	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
}

The caller renders it; neither front-end decides what is in it.

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