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 ¶
- Variables
- func ValidateName(name string) error
- type Instance
- type Store
- func (s Store) Delete(name string) error
- func (s Store) Exists(name string) bool
- func (s Store) List() ([]*Instance, map[string]error, error)
- func (s Store) Load(name string) (*Instance, *spec.Definition, error)
- func (s Store) Path(name string) string
- func (s Store) Save(in *Instance, d *spec.Definition) error
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("no such instance")
ErrNotFound means there's no instance with that name.
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 ¶
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 ¶
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.
type Store ¶
type Store struct{ Root string }
Store keeps instances under one directory.
func (Store) Delete ¶
Delete removes an instance directory, including server files stored inside it. Server files in a custom ServerDir are left alone.
func (Store) List ¶
List returns every instance, sorted by name. Broken instances are returned with their error so `list` can still show them.