instance

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package instance stores installed servers ("instances") on disk.

Each instance has a directory holding instance.json (what was installed and with which settings), a copy of the definition it was installed from, the server files, and logs.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("no such instance")

ErrNotFound means there's no instance with that name.

View Source
var NameRe = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{0,39}$`)

NameRe is the allowed shape of instance names. Names become directory, service and container names, so they're kept conservative.

Functions

func ValidateName

func ValidateName(name string) error

ValidateName checks an instance name.

Types

type Instance

type Instance struct {
	Name     string `json:"name"`
	Service  string `json:"service"`
	Registry string `json:"registry"`
	// DefinitionVersion is the definition version last applied.
	DefinitionVersion string `json:"definition_version"`
	Target            string `json:"target"`
	// ServerDir holds the server files. It defaults to <dir>/server.
	ServerDir string `json:"server_dir"`
	// Settings holds raw values as the user gave them (or as generated),
	// so they can be re-resolved against newer definitions.
	Settings map[string]string `json:"settings"`
	Ports    map[string]int    `json:"ports"`
	// Expose lists private ports the user chose to open to the network
	// (for a stack's web UI on a home LAN, say). Private ports otherwise
	// listen on 127.0.0.1 only.
	Expose    []string  `json:"expose,omitempty"`
	Installed time.Time `json:"installed"`
	Updated   time.Time `json:"updated"`
	// BackupKeep is how many backups to keep. 0 means the default.
	BackupKeep int `json:"backup_keep,omitempty"`

	// Dir is the instance's own directory. Not stored.
	Dir string `json:"-"`
}

Instance is one installed server.

func (*Instance) ConsoleSocket

func (in *Instance) ConsoleSocket() string

ConsoleSocket is the path of the supervisor's console socket. It lives in the instance directory unless that path is too long for a Unix socket, in which case it moves to a short private per-user directory.

func (*Instance) Context

func (in *Instance) Context(d *spec.Definition, goos string) (spec.Context, error)

Context builds the template context for this instance.

func (*Instance) Exposed

func (in *Instance) Exposed(port string) bool

Exposed reports whether the user opened a private port to the network.

func (*Instance) LogDir

func (in *Instance) LogDir() string

LogDir is where the supervisor writes server logs.

type Store

type Store struct{ Root string }

Store keeps instances under one directory.

func (Store) Delete

func (s Store) Delete(name string) error

Delete removes an instance directory, including server files stored inside it. Server files in a custom ServerDir are left alone.

func (Store) Exists

func (s Store) Exists(name string) bool

Exists reports whether an instance exists.

func (Store) List

func (s Store) List() ([]*Instance, map[string]error, error)

List returns every instance, sorted by name. Broken instances are returned with their error so `list` can still show them.

func (Store) Load

func (s Store) Load(name string) (*Instance, *spec.Definition, error)

Load reads one instance and the definition it was installed from.

func (Store) Path

func (s Store) Path(name string) string

Path returns an instance's directory.

func (Store) Save

func (s Store) Save(in *Instance, d *spec.Definition) error

Save writes an instance and its definition snapshot. instance.json can hold passwords, so it's readable only by the owner.

Jump to

Keyboard shortcuts

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