app

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Overview

Package app holds mutti's use cases (up, down, list, ...). It orchestrates the engine, Compose, git and the identity files, and returns typed results; it never prints anything but the output of the commands it runs for the user.

Index

Constants

View Source
const (
	CodeDockerUnavailable = "docker-unavailable"
	CodeComposeMissing    = "compose-missing"
	CodeComposeTooOld     = "compose-too-old"
	CodeComposeFailed     = "compose-failed"
	CodeNoComposeFile     = "no-compose-file"
	CodeNoSuchDir         = "no-such-dir"
	CodeInvalidConfig     = "invalid-config"
	CodeInvalidName       = "invalid-name"
	CodeNameTaken         = "name-taken"
	CodeCopiedWorktree    = "copied-worktree"
	CodeStaleClaim        = "stale-claim"
	CodeHookFailed        = "hook-failed"
	CodeUnknownOverlay    = "unknown-overlay"
	CodeInstanceInUse     = "instance-in-use"
	CodeRemoteDaemon      = "remote-daemon"
	CodePoolsExhausted    = "address-pools-exhausted"
	CodeOpenFailed        = "open-failed"
	CodeReaperFailed      = "reaper-failed"
	CodeTeardownFailed    = "teardown-failed"
	CodeTrustFailed       = "trust-failed"
	CodeCancelled         = "cancelled" // mutti got a signal
)

Error codes.

View Source
const (
	RoleClaim     = "claim"
	RoleBootstrap = "bootstrap"
)

Roles of mutti's own volumes (engine.LabelRole).

View Source
const (
	CheckOK   = "ok"
	CheckWarn = "warn"
	CheckFail = "fail"
)

Check results.

View Source
const (
	StatusRunning = "running" // all containers run
	StatusPartial = "partial" // some containers run
	StatusStopped = "stopped" // containers exist, none runs
	StatusDown    = "down"    // no containers
)

Status of an instance's containers.

View Source
const (
	CodeNotNested   = "not-nested"
	CodeUnmappable  = "unmappable-path"
	CodeSelfUnknown = "self-unknown"
)

Error codes of nested mode.

View Source
const (
	LabelHostname   = "mutti.hostname"    // main hostname of the instance
	LabelRouteHosts = "mutti.route.hosts" // comma-separated hostnames routed to this service
	LabelRoutePaths = "mutti.route.paths" // comma-separated path prefixes on the main hostname
	LabelRoutePort  = "mutti.route.port"  // container port the router sends traffic to
	LabelRouter     = "mutti.router"      // name of the router that serves the instance
	RoleIngress     = "ingress"           // engine.LabelRole of an instance's ingress network

	CodeRouterFailed = "router-failed" // error code
)

Labels mutti puts on instance containers through the override.

View Source
const (
	LabelCA           = "mutti.ca"       // fingerprint of the CA whose certificates the router serves
	CodeRouterForeign = "router-foreign" // the router belongs to another mutti state
)

Router ownership.

View Source
const (
	LabelRun    = "mutti.run"    // run id, on everything a run creates
	LabelReaper = "mutti.reaper" // run id, on the run's Ryuk container (which must not reap itself)
	RoleReaper  = "reaper"
)

Labels of ephemeral runs.

View Source
const (
	CodeNotGit       = "not-git"
	CodeGitFailed    = "git-failed"
	CodeDirtyTree    = "dirty-worktree"
	CodeMainWorktree = "main-worktree"
)

Error codes of the worktree commands.

View Source
const CodeHostnameTaken = "hostname-taken"

CodeHostnameTaken means an instance's hostname is held by another instance.

View Source
const CodeNoData = "no-data"

CodeNoData means the instance to copy data from has none.

View Source
const CodeNoRoute = "no-route"

CodeNoRoute means a service is not reachable through the router.

View Source
const CodeRunInstance = "run-instance"

CodeRunInstance means a command would change the instance a mutti run manages.

View Source
const DefaultDomain = "localhost"

DefaultDomain is the base domain of every hostname. RFC 6761 reserves it for loopback, so it resolves without any DNS setup and browsers treat it as a secure context.

View Source
const HelperImage = "busybox:1.37@sha256:bdf57e528e45e4433820e045b29b4597825a1c9e38353532d90a01445013f82e"

HelperImage runs mutti's one-off jobs, such as copying volumes. Pinned by digest.

View Source
const LabelDir = "mutti.dir"

LabelDir is where the Compose project lives, relative to the worktree (engine.LabelPath).

View Source
const LabelOptional = "mutti.optional"

LabelOptional marks a service behind a Compose profile, which only runs when asked for.

View Source
const LabelOrigin = "mutti.origin"

LabelOrigin says where the paths in a resource's labels are valid (see origin).

Variables

This section is empty.

Functions

func DomainFromEnv

func DomainFromEnv(getenv func(string) string) (string, error)

DomainFromEnv returns the base domain from $MUTTI_DOMAIN, or DefaultDomain.

func NewRunID

func NewRunID(now time.Time) string

NewRunID returns a unique id for a run: base36 seconds since 1970, then random hex. It sorts by time, says when it was made, and is a valid part of a DNS label.

Types

type App

type App struct {
	Engine  engine.Engine
	Compose compose.Runner
	Git     Git
	Dirs    home.Dirs
	Host    Host
	IO      compose.IO // streams of commands run on the user's behalf
	Domain  string     // base domain for hostnames, e.g. "localhost"
	Now     func() time.Time
	// Probe sends a GET to url with the Host header set to host and returns the status code.
	Probe func(ctx context.Context, url, host string) (int, error)
	// ReadyTimeout bounds how long up waits for the router; zero means 20 seconds.
	ReadyTimeout time.Duration
	Trusts       TrustStore
	// DialReaper connects to a run's reaper and registers filters; nil means reaper.Dial.
	DialReaper func(ctx context.Context, addr string, filters ...string) (io.Closer, error)
}

App wires mutti's dependencies.

func (*App) Attach

func (a *App) Attach(ctx context.Context, dir string, detach bool) (*Instance, error)

Attach connects the container mutti runs in to an instance's ingress network, so it reaches the instance's services by name and its hostnames through the router, e.g. for tests in a CI step container.

func (*App) ComposePassthrough

func (a *App) ComposePassthrough(ctx context.Context, dir string, sel Selection, args []string) (int, error)

ComposePassthrough runs any `docker compose` command against the instance. It is the escape hatch for everything mutti has no command of its own for.

func (*App) Destroy

func (a *App) Destroy(ctx context.Context, dir string) (*Instance, error)

Destroy removes everything of the instance: containers, networks, volumes, its claim and generated files. The identity file stays, so the next up uses the same name.

func (*App) Details added in v0.2.0

func (a *App) Details(ctx context.Context, instance string) ([]ServiceDetails, error)

Details describes the containers of the named instance service by service. It takes the instance's name rather than its directory, so it is cheap enough to ask every few seconds.

func (*App) Diagnose added in v0.2.0

func (a *App) Diagnose(ctx context.Context, dir string, services ...string) ([]Diagnosis, error)

Diagnose explains the services of dir's instance that are not well, or the named services whatever their state.

func (*App) Doctor

func (a *App) Doctor(ctx context.Context, dir string) *Report

Doctor checks the environment mutti depends on and, if dir is inside a project, the project.

func (*App) Down

func (a *App) Down(ctx context.Context, dir string, sel Selection) (*Instance, error)

Down removes the instance's containers and networks and keeps its volumes.

func (*App) Env

func (a *App) Env(inst *Instance) []string

Env returns the MUTTI_* variables available to Compose interpolation, hooks and exec. MUTTI_DOCKER_GID is only set when the socket's group is known; use ${MUTTI_DOCKER_GID:-...}. MUTTI_DOCKER_SOCKET is the Docker socket's host path, to mount where a container needs Docker. MUTTI_GIT_COMMON_DIR, the repository's shared git directory, is set inside git: a linked worktree's .git points there, so a container running git mounts it at the same path.

func (*App) EnvOf

func (a *App) EnvOf(ctx context.Context, dir string) ([]string, error)

EnvOf returns the MUTTI_* variables of the instance of dir.

func (*App) Events

func (a *App) Events(ctx context.Context) (<-chan InstanceEvent, <-chan error)

Events streams what happens to the containers of every instance until ctx ends. mutti's own helper containers (probes, copies, reapers) are left out. The error channel gets one error when the stream from Docker fails; the event channel closes either way, and has to be read until it does.

func (*App) Exec

func (a *App) Exec(ctx context.Context, dir, service string, cmd []string, opts ExecOptions) (int, error)

Exec runs a command in a service of the instance and returns its exit code.

func (*App) Init

func (a *App) Init(ctx context.Context, dir string, opts InitOptions) (*InitPlan, error)

Init plans writing mutti's defaults into the project: an x-mutti block in the Compose file, which zero config does not need but makes them visible and editable, and a section in AGENTS.md telling AI coding agents how to use the environment. The changed Compose file is checked with docker compose before it is planned.

func (*App) InitApply

func (a *App) InitApply(plan *InitPlan) error

InitApply writes a plan.

func (*App) List

func (a *App) List(ctx context.Context) ([]Summary, error)

List returns every instance on the machine, sorted by project and name. It reads all state with two daemon calls.

func (*App) Open

func (a *App) Open(ctx context.Context, dir, service string) (string, error)

Open opens a service's URL (see URL) in the browser.

func (*App) Prompt

func (a *App) Prompt(ctx context.Context, dir string) string

Prompt is a short state line for shell prompts: "<instance> <status> <running>/<total>", or "" outside an instance. It skips Compose entirely to stay fast, and never fails: a prompt has no place for errors.

func (*App) Reconcile

func (a *App) Reconcile(ctx context.Context) (*RouterStatus, error)

Reconcile brings the router in line with what runs: it starts the router if needed, attaches it to every ingress network under the instances' hostnames, and writes certificates and routes. Everything it does is derived from Docker state, so running it again is harmless.

func (*App) Remove added in v0.2.0

func (a *App) Remove(ctx context.Context, name string) error

Remove removes everything of the named instance from Docker and from mutti's state: its containers, networks, volumes and claim. It works by labels alone, so it needs neither the worktree nor Compose: it removes what a deleted worktree or a broken project left behind.

func (*App) Rename

func (a *App) Rename(ctx context.Context, dir, name string) (*Instance, error)

Rename gives the worktree's instance a new name and a new identity id. Data does not move between names, so the instance must have no containers or volumes left.

func (*App) Reset

func (a *App) Reset(ctx context.Context, dir string, opts UpOptions) (*UpResult, error)

Reset deletes the instance's data and starts it fresh: containers and volumes go, the bootstrap hooks run again. Name, claim and routes stay.

func (*App) Resolve

func (a *App) Resolve(ctx context.Context, dir string) (*Instance, error)

Resolve finds the instance for the worktree containing dir, which must be absolute. Inside the command of a mutti run (MUTTI_RUN_ID and MUTTI_INSTANCE set by it), that is the run's instance, so the command can work on it with mutti exec, mutti compose and the like.

func (*App) Restart added in v0.2.0

func (a *App) Restart(ctx context.Context, dir string, sel Selection, services ...string) (*Instance, error)

Restart restarts the instance's running containers, or those of the given services.

func (*App) RouterCheck added in v0.2.0

func (a *App) RouterCheck(ctx context.Context) Check

RouterCheck tells whether the router runs as it should, without touching it.

func (*App) RouterRestart

func (a *App) RouterRestart(ctx context.Context) (*RouterStatus, error)

RouterRestart replaces the router container, e.g. after it was changed by hand.

func (*App) Run

func (a *App) Run(ctx context.Context, dir string, opts RunOptions) (res *RunResult, err error)

Run starts a fresh, throwaway instance of the worktree's project, runs a command against it and removes the instance with all its data, whatever happens: a reaper container removes it even if mutti is killed. The result carries the command's exit code; a teardown that fails after a successful command is an error.

func (*App) RunCommand

func (a *App) RunCommand(ctx context.Context, dir string, c extend.Command, args []string) (int, error)

RunCommand runs a custom command: a host command as a process in the worktree root, a service command's script with sh (or bash) inside the service, as the configured user. Both get the MUTTI_* variables; the exit code is the command's.

func (*App) Services

func (a *App) Services(ctx context.Context, dir string) []string

Services returns the service names of the project of dir, for shell completion.

func (*App) Shell

func (a *App) Shell(ctx context.Context, dir, service string, opts ExecOptions) (int, error)

Shell opens an interactive shell in a service, by default the main one.

func (*App) Status

func (a *App) Status(ctx context.Context, dir string) (*InstanceStatus, error)

Status describes the instance of dir service by service.

func (*App) Stop

func (a *App) Stop(ctx context.Context, dir string, sel Selection, services ...string) (*Instance, error)

Stop stops the instance's containers, or only those of the given services, and keeps everything else.

func (*App) Sweep

func (a *App) Sweep(ctx context.Context, olderThan time.Duration) error

Sweep removes the leftovers of finished runs: of every run whose reaper is gone (it cannot remove a network the router still uses), and of every run older than olderThan, whatever happened to it.

Runs are found by their ingress networks only. mutti creates those itself, before any container of the run, and removes them after the containers. Container labels are no evidence: an image can carry any label, and a container of another project with mutti.run must not get that project purged.

func (*App) SweepHooks

func (a *App) SweepHooks(ctx context.Context, dir string, olderThan time.Duration) (bool, error)

SweepHooks runs x-mutti.hooks.sweep in the running instance of dir, with MUTTI_SWEEP_OLDER_THAN (seconds) set: the project removes per-run resources it made itself, such as test databases named after run ids. It reports whether hooks ran.

func (*App) Tidy

func (a *App) Tidy(ctx context.Context, opts TidyOptions) (*TidyResult, error)

Tidy removes instances whose worktree is gone or no longer holds their identity, and with Idle stops running instances nobody used for that long. An instance counts as used by every mutti command on it and by git activity in its worktree; browsing it does not count.

func (*App) Trust

func (a *App) Trust(_ context.Context, uninstall bool) (*TrustResult, error)

Trust makes the system and the browsers trust mutti's local CA, or stops them from it.

func (*App) URL

func (a *App) URL(ctx context.Context, dir, service string) (string, error)

URL returns the HTTPS URL of a service, or of the instance's main hostname for "". It needs no running containers: the URL follows from the configuration.

func (*App) Up

func (a *App) Up(ctx context.Context, dir string, opts UpOptions) (*UpResult, error)

Up claims the instance, starts it and waits until it is healthy, then runs the hooks.

func (*App) WorktreeAdd

func (a *App) WorktreeAdd(ctx context.Context, dir string, opts WorktreeAddOptions) (*WorktreeResult, error)

WorktreeAdd creates a git worktree and starts its instance.

func (*App) WorktreeNames

func (a *App) WorktreeNames(ctx context.Context, dir string) []string

WorktreeNames returns the names worktree remove accepts, for shell completion.

func (*App) WorktreeRemove

func (a *App) WorktreeRemove(ctx context.Context, dir string, opts WorktreeRemoveOptions) (string, error)

WorktreeRemove destroys a worktree's instance and removes the worktree. The branch stays. It refuses to touch anything while the worktree has uncommitted changes, unless forced, so no data is destroyed for a removal git would refuse anyway.

type Check

type Check struct {
	Name   string `json:"name"`
	Status string `json:"status"`
	Detail string `json:"detail"`
	Hint   string `json:"hint,omitempty"`
}

Check is one finding of Doctor.

type Diagnosis added in v0.2.0

type Diagnosis struct {
	Service      string        `json:"service"`
	State        string        `json:"state"`
	Status       string        `json:"status"`
	Problem      string        `json:"problem"`        // what is wrong, in a few words
	Hint         string        `json:"hint,omitempty"` // what to do next
	ExitCode     int           `json:"exitCode,omitempty"`
	OOMKilled    bool          `json:"oomKilled,omitempty"`
	RestartCount int           `json:"restartCount,omitempty"`
	Health       []HealthCheck `json:"health,omitempty"` // the last health checks, oldest first
	Logs         string        `json:"logs"`             // the last lines the service printed
}

Diagnosis explains why a service is not well: what went wrong, what its health checks said and what it printed last.

type Error

type Error struct {
	Code    string
	Message string
	Hint    string
	Err     error
}

Error is a failure the user can act on. Code is stable and shows up in JSON output.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ExecOptions

type ExecOptions struct {
	User    string   // overrides x-mutti exec.user
	Workdir string   // working directory in the container; empty: the image's
	Env     []string // KEY=VALUE pairs on top of the MUTTI_* variables
}

ExecOptions configure Exec.

type FeatureStatus

type FeatureStatus struct {
	Name      string `json:"name"`
	Since     string `json:"since"`
	Required  bool   `json:"required"`
	Available bool   `json:"available"`
	Use       string `json:"use"`
}

FeatureStatus tells whether the installed Compose has a feature mutti knows about.

type Git

type Git interface {
	Find(ctx context.Context, dir string) (gitdir.Info, bool, error)
	Branch(ctx context.Context, dir string) (string, error)
	AddWorktree(ctx context.Context, dir, path, branch, newBranch, base string) error
	RemoveWorktree(ctx context.Context, dir, path string, force bool) error
	DeleteBranch(ctx context.Context, dir, branch string) error
	Dirty(ctx context.Context, dir string) (bool, error)
	Worktrees(ctx context.Context, commonDir string) ([]gitdir.Worktree, error)
}

Git is the part of the git binary mutti uses.

type HealthCheck added in v0.2.0

type HealthCheck struct {
	Time     time.Time `json:"time"`
	ExitCode int       `json:"exitCode"`
	Output   string    `json:"output"`
}

HealthCheck is one health check result.

type Host

type Host struct {
	UID, GID int
	Getenv   func(string) string
	LookPath func(string) (string, error)
	StdinTTY bool // stdin is a terminal, so exec may allocate a TTY
	IPv6     bool // the loopback interface has ::1
	// ContainerID is the container mutti runs in, empty on a plain host (hostenv.SelfContainer).
	ContainerID string
	// DockerGID is the group of the Docker socket, -1 when unknown (hostenv.SocketGID).
	DockerGID int
	// DockerSocket is the Docker socket's path on the Docker host (hostenv.DockerSocket).
	DockerSocket string
	// OpenURL opens a URL in the user's browser.
	OpenURL func(url string) error
	// PortFree reports whether a TCP port on 127.0.0.1 is free.
	PortFree func(port uint16) bool
	// SystemRoots returns the certificate authorities the system trusts.
	SystemRoots func() (*x509.CertPool, error)
}

Host describes the machine mutti runs on.

type HostConflict

type HostConflict struct {
	Instance string `json:"instance"`
	Host     string `json:"host"`
	Owner    string `json:"owner"`             // the instance holding the hostname
	Service  string `json:"service,omitempty"` // the owner's service, when one of its routes holds it
}

HostConflict is an instance the router leaves out because another one holds its hostname.

type InitOptions

type InitOptions struct {
	NoAgents bool // leave AGENTS.md alone
}

InitOptions configure Init.

type InitPlan

type InitPlan struct {
	// ComposeFile gets the x-mutti block; empty when the project has one already.
	ComposeFile string        `json:"composeFile,omitempty"`
	Draft       project.Draft `json:"draft"`
	XMutti      string        `json:"xMutti,omitempty"` // the block written into ComposeFile
	// AgentsFile gets the mutti section for AI coding agents; empty with InitOptions.NoAgents.
	AgentsFile    string `json:"agentsFile,omitempty"`
	AgentsSection string `json:"agentsSection,omitempty"`
	// contains filtered or unexported fields
}

InitPlan is what mutti init would change; nothing is written until InitApply.

func (*InitPlan) Empty

func (p *InitPlan) Empty() bool

Empty reports whether there is nothing to write.

type Instance

type Instance struct {
	Name         string // instance name = Compose project name
	Project      string
	Worktree     string
	ID           string // empty until the instance was claimed once
	Root         string // worktree root
	HostPath     string // Root as the Docker host sees it; differs when mutti runs in a container
	GitDir       string // per-worktree git admin dir, empty outside git
	CommonDir    string // the repository's shared git dir, empty outside git
	IdentityPath string
	Hostname     string
	Files        project.Files
	Model        *compose.Model
	Config       project.Config
	// contains filtered or unexported fields
}

Instance is the environment of one worktree, as resolved from disk. Nothing on the daemon is touched while resolving.

type InstanceEvent

type InstanceEvent struct {
	Time      time.Time `json:"time"`
	Instance  string    `json:"instance"`
	Service   string    `json:"service,omitempty"`
	Container string    `json:"container"`
	// Event is created, started, stopped, removed, paused, unpaused, healthy or unhealthy.
	Event    string `json:"event"`
	ExitCode *int   `json:"exitCode,omitempty"` // with stopped
}

InstanceEvent is something that happened to a container of an instance.

type InstanceStatus

type InstanceStatus struct {
	Name     string          `json:"name"`
	Project  string          `json:"project"`
	Path     string          `json:"path"`
	Branch   string          `json:"branch,omitempty"`
	URL      string          `json:"url,omitempty"`
	Services []ServiceStatus `json:"services"`
}

InstanceStatus is the detailed state of one worktree's instance.

type PortSummary

type PortSummary struct {
	Service       string `json:"service"`
	Address       string `json:"address"` // host:port, with "/udp" for UDP
	ContainerPort uint16 `json:"containerPort"`
	Routed        bool   `json:"routed"` // the service is also reachable through the router
}

PortSummary is a published port of a service.

type Report

type Report struct {
	Checks          []Check         `json:"checks"`
	ComposeFeatures []FeatureStatus `json:"composeFeatures,omitempty"`
}

Report is the result of Doctor.

func (*Report) Failed

func (r *Report) Failed() bool

Failed reports whether any check failed.

type RouterStatus

type RouterStatus struct {
	Name      string   `json:"name"`
	HTTPPort  uint16   `json:"httpPort"`
	HTTPSPort uint16   `json:"httpsPort"`
	Instances []string `json:"instances"` // instances with at least one routed, running service
	// Conflicts are instances left out because another one holds a hostname they need.
	Conflicts []HostConflict `json:"conflicts,omitempty"`
	// contains filtered or unexported fields
}

RouterStatus describes the router after a reconcile.

type RunOptions

type RunOptions struct {
	Selection
	Build    bool
	Services []string // start only these and what they depend on; empty: all
	Service  string   // run Command in a one-off container of this service; empty: on the host
	User     string   // with Service: like ExecOptions.User
	Command  []string // what to run
	LogsDir  string   // where the services' logs go; empty: <worktree>/.mutti/local/runs/<run id>
}

RunOptions configure Run.

type RunResult

type RunResult struct {
	RunID    string `json:"runId"`
	Instance string `json:"instance"`
	URL      string `json:"url,omitempty"`
	ExitCode int    `json:"exitCode"`
	Logs     string `json:"logs"` // file with the logs of all services
}

RunResult describes a finished run.

type Selection

type Selection struct {
	Overlays []string `json:"overlays,omitempty"` // x-mutti overlay names
	Profiles []string `json:"profiles,omitempty"` // Compose profiles
}

Selection picks optional parts of a project for a command. Commands given none use the one the instance was last started with, so they see the services that actually run.

type ServiceDetails added in v0.2.0

type ServiceDetails struct {
	Service      string       `json:"service"`
	Image        string       `json:"image"`
	StartedAt    time.Time    `json:"startedAt,omitzero"`
	RestartCount int          `json:"restartCount"`
	Health       *HealthCheck `json:"health,omitempty"` // the last health check
	Usage        *Usage       `json:"usage,omitempty"`  // while it runs
}

ServiceDetails is how the container of a service runs: what it was made from, since when, and what it uses at the moment.

type ServiceStatus

type ServiceStatus struct {
	Service string `json:"service"`
	State   string `json:"state"`  // running, exited, ... or "missing" when not created
	Status  string `json:"status"` // Docker's text, e.g. "Up 3 minutes (healthy)"
	// Completed marks a one-shot service that did its job, such as installing dependencies.
	Completed bool `json:"completed,omitempty"`
	// Profiles are the Compose profiles of an optional service, which runs only when asked for.
	Profiles []string      `json:"profiles,omitempty"`
	URLs     []string      `json:"urls,omitempty"`
	Ports    []PortSummary `json:"ports,omitempty"`
}

ServiceStatus is one service in Status.

type Summary

type Summary struct {
	Name     string        `json:"name"`
	Project  string        `json:"project"`
	Path     string        `json:"path"` // where its Compose project lives, a subdirectory of its worktree or the worktree
	Branch   string        `json:"branch,omitempty"`
	Status   string        `json:"status"`
	Running  int           `json:"running"`
	Total    int           `json:"total"`
	Orphaned bool          `json:"orphaned"`       // the worktree is gone or holds another identity
	URLs     []string      `json:"urls,omitempty"` // routed URLs, the main hostname first
	Ports    []PortSummary `json:"ports,omitempty"`
}

Summary describes one instance on the machine.

type TidyOptions

type TidyOptions struct {
	Project string        // only this project's instances; empty: all
	Idle    time.Duration // also stop running instances unused for this long; 0: don't
	Apply   bool          // act; otherwise only report
}

TidyOptions configure Tidy.

type TidyResult

type TidyResult struct {
	Removed []Summary `json:"removed"` // worktree gone or holding another identity
	Stopped []Summary `json:"stopped"` // running but idle
}

TidyResult lists what Tidy removed or stopped (or would).

type TrustResult

type TrustResult struct {
	CertFile  string `json:"certFile"`
	Installed bool   `json:"installed"` // false: removed
	// Browsers is false when certutil is missing, so Firefox and Chromium were not updated.
	Browsers bool `json:"browsers"`
}

TrustResult describes what mutti trust changed.

type TrustStore

type TrustStore interface {
	Install(certFile string) error
	Uninstall(certFile string) error
}

TrustStore changes which certificate authorities the system and the browsers trust.

type UpOptions

type UpOptions struct {
	Selection
	Build    bool     // rebuild images before starting
	Services []string // start only these and what they depend on; empty: all
	// contains filtered or unexported fields
}

UpOptions configure Up.

type UpResult

type UpResult struct {
	Instance     *Instance
	Bootstrapped bool   // the bootstrap hooks ran during this up
	URL          string // main URL through the router, empty if nothing is routed
}

UpResult describes a started instance.

type Usage added in v0.2.0

type Usage struct {
	Sampled     time.Time     `json:"sampled"`
	CPU         time.Duration `json:"cpu"`         // CPU time used since it started, over all cores
	Memory      uint64        `json:"memory"`      // bytes
	MemoryLimit uint64        `json:"memoryLimit"` // bytes
}

Usage is one sample of what a container uses.

type WorktreeAddOptions

type WorktreeAddOptions struct {
	Name   string // name of the worktree; also the new branch, unless Branch is set
	Branch string // check out this existing branch instead of creating one
	From   string // base of the new branch; empty: the current HEAD
	Path   string // where to put it; empty: next to the main worktree as <repo>-<name>
	// DataFrom copies the volumes of another worktree's instance ("main", a name or a path)
	// instead of bootstrapping; after-clone hooks run instead of bootstrap hooks.
	DataFrom string
	NoUp     bool // only create the worktree
	Up       UpOptions
}

WorktreeAddOptions configure WorktreeAdd.

type WorktreeRemoveOptions

type WorktreeRemoveOptions struct {
	Target string // name (as given to add) or path of the worktree
	Force  bool   // also drop uncommitted changes
}

WorktreeRemoveOptions configure WorktreeRemove.

type WorktreeResult

type WorktreeResult struct {
	Path   string
	Branch string
	Copied []string  // paths copied from the main worktree (x-mutti.worktree.copy)
	Cloned []string  // volumes copied from DataFrom
	Up     *UpResult // nil with NoUp
}

WorktreeResult describes a created worktree.

Jump to

Keyboard shortcuts

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