Documentation
¶
Index ¶
- type ExecOptions
- type ExecSession
- type Image
- type InterfaceAddress
- type InterfaceCounters
- type Manager
- func (m *Manager) Create(uid int, image string, password string, sshKey string) (*Webspace, error)
- func (m *Manager) Get(uid int, userHint *iam.User) (*Webspace, error)
- func (m *Manager) GetAll() ([]*Webspace, error)
- func (m *Manager) Healthy() bool
- func (m *Manager) Images() ([]Image, error)
- func (m *Manager) Lock(uid int)
- func (m *Manager) Shutdown(ctx context.Context)
- func (m *Manager) Start(ctx context.Context) error
- func (m *Manager) Unlock(uid int)
- type NetworkInterface
- type PortForward
- type PortHook
- type PortsManager
- func (p *PortsManager) Add(ctx context.Context, e uint16, backendAddr *net.TCPAddr, hook PortHook) error
- func (p *PortsManager) AddAll(ctx context.Context, w *Webspace, addr string) error
- func (p *PortsManager) Remove(ctx context.Context, e uint16, updateK8s bool) error
- func (p *PortsManager) Shutdown(ctx context.Context)
- func (p *PortsManager) Trim(ctx context.Context, all []*Webspace) error
- type State
- type Traefik
- type TraefikKubernetes
- type TraefikRedis
- type Usage
- type Webspace
- func (w *Webspace) AddDomain(domain string) error
- func (w *Webspace) AddPort(external uint16, internal uint16) (uint16, error)
- func (w *Webspace) AwaitIP() (string, error)
- func (w *Webspace) Boot() error
- func (w *Webspace) ClearLog() error
- func (w *Webspace) Console(width, height int) (io.ReadWriteCloser, func(int, int) error, error)
- func (w *Webspace) DefaultDomain(ctx context.Context) (string, error)
- func (w *Webspace) Delete() error
- func (w *Webspace) EnsureStarted() (string, error)
- func (w *Webspace) Exec(cmd string, ensureBooted bool) (int, string, string, error)
- func (w *Webspace) ExecInteractive(opts ExecOptions) (ExecSession, error)
- func (w *Webspace) GetDomains(ctx context.Context) ([]string, error)
- func (w *Webspace) GetIP(state *lxdApi.InstanceState) (string, error)
- func (w *Webspace) GetUser(ctx context.Context) (*iam.User, error)
- func (w *Webspace) InstanceName() string
- func (w *Webspace) Log() (io.ReadCloser, error)
- func (w *Webspace) Reboot() error
- func (w *Webspace) RemoveDomain(ctx context.Context, domain string) error
- func (w *Webspace) RemovePort(external uint16) error
- func (w *Webspace) Save() error
- func (w *Webspace) Shutdown() error
- func (w *Webspace) State() (State, error)
- func (w *Webspace) Sync(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecOptions ¶ added in v0.2.1
type ExecOptions struct {
Command []string `json:"command"`
User uint32 `json:"user"`
Group uint32 `json:"group"`
Environment map[string]string `json:"environment"`
Width int `json:"width"`
Height int `json:"height"`
WorkingDirectory string `json:"workingDirectory"`
}
ExecOptions specifies options for executing a command in a webspace
type ExecSession ¶ added in v0.2.1
type ExecSession interface {
IO() io.ReadWriteCloser
Resize(int, int) error
Signal(int) error
Await() (int, error)
ExitCode() int
}
ExecSession represents an interactive webspace exec session
type Image ¶
type Image struct {
Aliases []lxdApi.ImageAlias `json:"aliases"`
Fingerprint string `json:"fingerprint"`
Properties map[string]string `json:"properties"`
Size int64 `json:"size"`
}
Image represents an LXD image
type InterfaceAddress ¶
type InterfaceAddress struct {
Family string `json:"family"`
Address string `json:"address"`
Netmask string `json:"netmask"`
Scope string `json:"scope"`
}
InterfaceAddress describes a network interface's address
type InterfaceCounters ¶
type InterfaceCounters struct {
BytesReceived int64 `json:"bytesReceived"`
BytesSent int64 `json:"bytesSent"`
PacketsReceived int64 `json:"packetsReceived"`
PacketsSent int64 `json:"packetsSent"`
}
InterfaceCounters describes a network interface's statistics
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages webspace containers
func NewManager ¶
NewManager returns a new Manager instance
type NetworkInterface ¶
type NetworkInterface struct {
MAC string `json:"mac"`
MTU int `json:"mtu"`
State string `json:"state"`
Counters InterfaceCounters `json:"counters"`
Addresses []InterfaceAddress `json:"addresses"`
}
NetworkInterface describe's a webspace's network interface
type PortForward ¶
type PortForward struct {
// contains filtered or unexported fields
}
PortForward represents an active port forwarding
func NewPortForward ¶
NewPortForward creates and starts a port forward
type PortHook ¶
type PortHook func(f *PortForward) error
PortHook represents a function to run before connecting to the backend
type PortsManager ¶
type PortsManager struct {
// contains filtered or unexported fields
}
PortsManager manages TCP port forwarding
func NewPortsManager ¶
func NewPortsManager(cfg *config.Config) (*PortsManager, error)
NewPortsManager creates a new TCP port forward manager
func (*PortsManager) Add ¶
func (p *PortsManager) Add(ctx context.Context, e uint16, backendAddr *net.TCPAddr, hook PortHook) error
Add creates a new port forwarding
func (*PortsManager) Shutdown ¶
func (p *PortsManager) Shutdown(ctx context.Context)
Shutdown stops and removes all port forwards
type State ¶
type State struct {
Running bool `json:"running"`
Uptime float64 `json:"uptime"`
Usage Usage `json:"usage"`
NetworkInterfaces map[string]NetworkInterface `json:"networkInterfaces"`
}
State describes a webspace's state
type Traefik ¶
type Traefik interface {
// ClearAll cleans all configuration for all instances
ClearAll(ctx context.Context) error
// ClearConfig cleans out any configuration for an instance
ClearConfig(ctx context.Context, n string) error
// GenerateConfig generates configuration for an instance
GenerateConfig(ctx context.Context, ws *Webspace, addr string) error
}
Traefik represents a method of programming Traefik router configuration
func NewTraefikKubernetes ¶
NewTraefikKubernetes manages webspace configuration for Traefik via Kubernetes resources
func NewTraefikRedis ¶
NewTraefikRedis creates a new Traefik config manager using Redis
type TraefikKubernetes ¶
type TraefikKubernetes struct {
// contains filtered or unexported fields
}
TraefikKubernetes manages webspace configuration for Traefik via Kubernetes resources
func (*TraefikKubernetes) ClearAll ¶ added in v0.5.0
func (t *TraefikKubernetes) ClearAll(ctx context.Context) error
func (*TraefikKubernetes) ClearConfig ¶
func (t *TraefikKubernetes) ClearConfig(ctx context.Context, n string) error
ClearConfig cleans out any configuration for an instance
func (*TraefikKubernetes) GenerateConfig ¶
GenerateConfig generates new Traefik configuration for a webspace
type TraefikRedis ¶
type TraefikRedis struct {
// contains filtered or unexported fields
}
TraefikRedis manages webspace configuration for Traefik via Redis
func (*TraefikRedis) ClearAll ¶ added in v0.5.0
func (t *TraefikRedis) ClearAll(ctx context.Context) error
func (*TraefikRedis) ClearConfig ¶
func (t *TraefikRedis) ClearConfig(ctx context.Context, n string) error
ClearConfig cleans out any configuration for an instance
func (*TraefikRedis) GenerateConfig ¶
GenerateConfig generates new Traefik configuration for a webspace
type Usage ¶
type Usage struct {
CPU int64 `json:"cpu"`
Disks map[string]int64 `json:"disks"`
Memory int64 `json:"memory"`
Processes int64 `json:"processes"`
}
Usage describes a webspace's resource usage
type Webspace ¶
type Webspace struct {
UserID int `json:"user"`
Config config.WebspaceConfig `json:"config"`
Domains []string `json:"domains"`
Ports map[uint16]uint16 `json:"ports"`
// contains filtered or unexported fields
}
Webspace represents a webspace with all of its configuration and state
func (*Webspace) DefaultDomain ¶ added in v0.3.1
DefaultDomain returns the default domain for the webspace
func (*Webspace) EnsureStarted ¶
EnsureStarted starts a webspace if it isn't running (delaying by the startup delay) and returns its IP address after
func (*Webspace) ExecInteractive ¶ added in v0.2.1
func (w *Webspace) ExecInteractive(opts ExecOptions) (ExecSession, error)
ExecInteractive runs a command in a webspace (with a PTY)
func (*Webspace) GetDomains ¶
GetDomains gets all domains (including the default one, which can change because of usernames!)
func (*Webspace) GetIP ¶
func (w *Webspace) GetIP(state *lxdApi.InstanceState) (string, error)
GetIP retrieves the webspace's primary IP address
func (*Webspace) InstanceName ¶
InstanceName uses the suffix to calculate the name of the instance
func (*Webspace) Log ¶
func (w *Webspace) Log() (io.ReadCloser, error)
Log returns the webspace's `/dev/console` log
func (*Webspace) RemoveDomain ¶
RemoveDomain removes an existing domain
func (*Webspace) RemovePort ¶
RemovePort removes a port forwarding