Documentation
¶
Index ¶
- func CgroupNSEnabled() (bool, error)
- func CombinedOutput(config EnterConfig) ([]byte, error)
- func Enter(config EnterConfig) error
- func Init() error
- func MountCgroups(root string) error
- func NewSignalForwarder() signalForwarder
- func WriteEnvironment(path string, env EnvVars) error
- type Box
- type Config
- type ContainerServer
- type DNSOverrides
- type Device
- type Devices
- type EnterConfig
- type EnvFile
- type EnvPair
- type EnvVars
- type ErrConnect
- type ExitError
- type File
- type FileOwner
- type Mount
- type Mounts
- type ProcessConfig
- type TTY
- type Winsize
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CgroupNSEnabled ¶
CgroupNSEnabled checks whether the system has cgroup namespaces enabled Based on internal function from runc https://github.com/opencontainers/runc/blob/029124da7af7360afa781a0234d1b083550f797c/libcontainer/configs/validate/validator.go#L122-L129
func CombinedOutput ¶
func CombinedOutput(config EnterConfig) ([]byte, error)
CombinedOutput runs a process within planet, returning the output as a byte buffer
func Enter ¶
func Enter(config EnterConfig) error
Enter is used to exec a process within the running container
func Init ¶
func Init() error
Init is implicitly called by the libcontainer logic and is used to start a process in the new namespaces and cgroups
func MountCgroups ¶
func NewSignalForwarder ¶
func NewSignalForwarder() signalForwarder
NewsignalForwarder creates a default signalForwarder
func WriteEnvironment ¶
WriteEnvironment writes provided environment variables to a file at the specified path.
Types ¶
type Box ¶
type Box struct { *libcontainer.Process libcontainer.Container // contains filtered or unexported fields }
Box defines a running planet container.
A box manages a number of resources including an init process and an API server that exposes a unix socket endpoint. Once started, the box can be shut down with Close.
func (*Box) Close ¶
Close shuts down the box. It is written to be safe to call multiple times in a row for extra robustness.
func (*Box) CombinedOutput ¶
func (b *Box) CombinedOutput(config ProcessConfig) ([]byte, error)
CombinedOutput runs a process within planet, returning the output as a byte buffer
type Config ¶
type Config struct { // InitArgs lists the command to execute and any arguments InitArgs []string // InitEnv lists the environment variables to pass to the process InitEnv []string // InitUser is a user running the init process InitUser string // EnvFiles has a list of files that will generated when process starts EnvFiles []EnvFile // Files is an optional list of files that will be placed // in the container when started Files []File // Rootfs is a root filesystem of the container Rootfs string // Mounts is a list of device/directory/file mounts passed to the server Mounts Mounts // Devices is a list of devices to create inside the container Devices Devices // Capabilities is a list of capabilities of this container Capabilities []string // DataDir is a directory where libcontainer stores the container state DataDir string // ProcessLabel specifies the SELinux process label ProcessLabel string // SELinux turns on SELinux support SELinux bool // FieldLogger specifies the logger log.FieldLogger }
Config defines the configuration of the planet container
type ContainerServer ¶
type ContainerServer interface {
Enter(cfg ProcessConfig) error
}
type DNSOverrides ¶
DNSOverrides is a command-line flag parser for DNS host/zone overrides
func (*DNSOverrides) Set ¶
func (d *DNSOverrides) Set(v string) error
Set sets the overrides value from a CLI flag
func (*DNSOverrides) String ¶
func (d *DNSOverrides) String() string
String formats overrides to a string
type Device ¶
type Device struct { // Path is the device path, treated as a glob Path string // Permissions is the device permissions Permissions string // FileMode is the device file mode FileMode os.FileMode // UID is the device user ID UID uint32 // GID is the device group ID GID uint32 }
Device represents a device that should be created in planet
type EnterConfig ¶
type EnterConfig struct { // Process specifies the process configuration to execute Process ProcessConfig // DataDir specifies the runc-specific data directory DataDir string // SELinux specifies whether SELinux support is on SELinux bool }
EnterConfig specifies the configuration to execute a command inside the container
type EnvPair ¶
type EnvPair struct { // Name is the name of the environment variable Name string `json:"name"` // Val defines the value of the environment variable Val string `json:"val"` }
EnvPair defines an environment variable
type EnvVars ¶
type EnvVars []EnvPair
EnvVars is a list of environment variables
func ReadEnvironment ¶
ReadEnvironment returns a list of all environment variables read from the file at the specified path.
func (*EnvVars) Delete ¶
Delete removes the environment variable named v from the list and returns its value
func (*EnvVars) Set ¶
Set parses v as a comma-separated list of name=value pairs. If a value contains a comma, it must be quoted.
type ErrConnect ¶
type ErrConnect struct {
Err error // Original error
}
func (*ErrConnect) Error ¶
func (e *ErrConnect) Error() string
type ExitError ¶
type ExitError struct { // Code specifies the process exit code Code int }
ExitError is an error that describes the event of a process exiting with a non-zero value.
type Mount ¶
type Mount struct { // Src defines the source for the mount on host Src string // Dst defines the mount point inside the container Dst string // Readonly specifies that the mount is created readonly Readonly bool // SkipIfMissing instructs to skip the mount if the Src is non-existent SkipIfMissing bool // Recursive indicates that all mount points inside this mount should also be mounted Recursive bool }
Mount defines a mapping from a host location to some location inside the container
type ProcessConfig ¶
type ProcessConfig struct { In io.Reader `json:"-"` Out io.Writer `json:"-"` TTY *TTY `json:"tty,omitempty"` Args []string `json:"args"` User string `json:"user"` Env EnvVars `json:"env,omitempty"` ProcessLabel string `json:"process_label,omitempty"` }
ProcessConfig is a configuration passed to the process started in the namespace of the container
func (*ProcessConfig) Environment ¶
func (e *ProcessConfig) Environment() []string
Environment returns a slice of environment variables in key=value format as required by libcontainer
func (*ProcessConfig) String ¶
func (e *ProcessConfig) String() string
String returns human-readable description of this configuration