Documentation
¶
Overview ¶
Package config reads application config.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrMissingBox = errors.New("missing 'box' section in codapi.json") ErrMissingStep = errors.New("missing 'step' section in codapi.json") )
Functions ¶
This section is empty.
Types ¶
type Box ¶
type Box struct {
Name string `json:"name"`
Image string `json:"image"`
Runtime string `json:"runtime"`
Host
Files []string `json:"files"`
}
A Box describes a specific container. There is an important difference between a "sandbox" and a "box". A box is a single container. A sandbox is an environment in which we run commands. A sandbox command can contain multiple steps, each of which runs in a separate box. So the relation sandbox -> box is 1 -> 1+.
type Command ¶
type Command struct {
Engine string `json:"engine"`
Entry string `json:"entry"`
Before *Step `json:"before"`
Steps []*Step `json:"steps"`
After *Step `json:"after"`
}
A Command describes a specific set of actions to take when executing a command in a sandbox.
type Config ¶
type Config struct {
PoolSize int `json:"pool_size"`
Verbose bool `json:"verbose"`
Box *Box `json:"box"`
Step *Step `json:"step"`
HTTP *HTTP `json:"http"`
// These are the available containers ("boxes").
Boxes map[string]*Box `json:"boxes"`
// These are the "sandboxes". Each sandbox can contain
// multiple commands, and each command can contain
// multiple steps. Each step is executed in a specific box.
Commands map[string]SandboxCommands `json:"commands"`
}
A Config describes application config.
func ReadBoxes ¶
ReadBoxes reads boxes config from the file system. It prefers the sandboxes dir if it exists, otherwise fallbacks to the boxes dir if it exists, and finally fallbacks to the boxes.json file.
func ReadCommands ¶
ReadCommands reads command configs from the file system. It prefers the sandboxes dir if it exists, otherwise fallbacks to the commands dir.
func ReadConfig ¶
ReadConfig reads application config from a JSON file.
func (*Config) CommandNames ¶
CommandNames returns configured command names.
type Host ¶
type Host struct {
CPU int `json:"cpu"`
Memory int `json:"memory"`
Storage string `json:"storage"`
Network string `json:"network"`
Writable bool `json:"writable"`
Volume string `json:"volume"`
Tmpfs []string `json:"tmpfs"`
CapAdd []string `json:"cap_add"`
CapDrop []string `json:"cap_drop"`
Ulimit []string `json:"ulimit"`
// do not use the ulimit nproc because it is
// a per-user setting, not a per-container setting
NProc int `json:"nproc"`
}
A Host describes container Host attributes.
type SandboxCommands ¶
SandboxCommands describes all commands available for a sandbox. command name : command
type Step ¶
type Step struct {
Box string `json:"box"`
Version string `json:"version"`
User string `json:"user"`
Action string `json:"action"`
Detach bool `json:"detach"`
Stdin bool `json:"stdin"`
Command []string `json:"command"`
Timeout int `json:"timeout"`
NOutput int `json:"noutput"`
}
A Step describes a single step of a command.