Documentation ¶
Overview ¶
Package container allows to run and manage multiple containers across multiple hosts, by talking directly to the container runtime on local or remote hosts.
Index ¶
Constants ¶
const (
// ConfigMountpoint is where host file-system is mounted in the -config container.
ConfigMountpoint = "/mnt/host"
)
const ( // StatusMissing is a value, which is set to ContainerStatus.Status field, // if stored container ID is not found. StatusMissing = "gone" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Container ¶
type Container struct { // Stores runtime configuration of the container. Config types.ContainerConfig `json:"config"` // Status of the container. Status *types.ContainerStatus `json:"status,omitempty"` // Runtime stores configuration for various container runtimes. Runtime RuntimeConfig `json:"runtime,omitempty"` }
Container represents public, serializable version of the container object.
It should be used for persisting and restoring container state with combination with New(), which make sure that the configuration is actually correct.
type Containers ¶
type Containers struct { // PreviousState stores previous state of the containers, which should be obtained and persisted // after containers modifications. PreviousState ContainersState `json:"previousState,omitempty"` // DesiredState is a user-defined desired containers configuration. DesiredState ContainersState `json:"desiredState,omitempty"` }
Containers allow to orchestrate and update multiple containers spread across multiple hosts and update their configurations.
func (*Containers) CheckCurrentState ¶
func (c *Containers) CheckCurrentState() error
CheckCurrentState checks the state of existing containers and updates their state.
func (*Containers) New ¶
func (c *Containers) New() (ContainersInterface, error)
New validates Containers configuration and returns "executable" containers object.
func (*Containers) Validate ¶
func (c *Containers) Validate() error
Validate validates Containers struct and all structs used underneath.
type ContainersInterface ¶
type ContainersInterface interface { CheckCurrentState() error Deploy() error StateToYaml() ([]byte, error) ToExported() *Containers DesiredState() ContainersState Containers() ContainersInterface }
ContainersInterface represents capabilities of containers struct.
func FromYaml ¶
func FromYaml(c []byte) (ContainersInterface, error)
FromYaml allows to restore containers state from YAML.
type ContainersState ¶
type ContainersState map[string]*HostConfiguredContainer
ContainersState represents states of multiple containers.
func (ContainersState) New ¶
func (s ContainersState) New() (ContainersStateInterface, error)
New validates ContainersState struct and returns operational containerState.
type ContainersStateInterface ¶
type ContainersStateInterface interface { CheckState() error RemoveContainer(containerName string) error CreateAndStart(containerName string) error Export() ContainersState }
ContainersStateInterface exports constainersState capabilities.
type Hook ¶
type Hook func() error
Hook is an action, which may be called before or after certain container operation, like starting or creating.
type Hooks ¶
type Hooks struct {
PostStart *Hook
}
Hooks defines type of hooks HostConfiguredContainer supports.
type HostConfiguredContainer ¶
type HostConfiguredContainer struct { Container Container `json:"container"` Host host.Host `json:"host"` ConfigFiles map[string]string `json:"configFiles,omitempty"` Hooks *Hooks `json:"-"` }
HostConfiguredContainer represents single container, running on remote host with it's configuration files.
func (*HostConfiguredContainer) New ¶
func (m *HostConfiguredContainer) New() (HostConfiguredContainerInterface, error)
New validates HostConfiguredContainer struct and return it's executable version.
func (*HostConfiguredContainer) Validate ¶
func (m *HostConfiguredContainer) Validate() error
Validate validates HostConfiguredContainer struct. All validation rules should be placed here.
type HostConfiguredContainerInterface ¶
type HostConfiguredContainerInterface interface { ConfigurationStatus() error Configure(paths []string) error Create() error Status() error Start() error Stop() error Delete() error }
HostConfiguredContainerInterface exports hostConfiguredContainer capabilities.
type InstanceInterface ¶
type InstanceInterface interface { Status() (types.ContainerStatus, error) Read(srcPath []string) ([]*types.File, error) Copy(files []*types.File) error Stat(paths []string) (map[string]os.FileMode, error) Start() error Stop() error Delete() error }
InstanceInterface represents containerInstance capabilities.
type Interface ¶
type Interface interface { // Methods to instantiate Instance. Create() (InstanceInterface, error) FromStatus() (InstanceInterface, error) // Helpers. UpdateStatus() error Start() error Stop() error Delete() error Status() *types.ContainerStatus // Getters. Config() types.ContainerConfig RuntimeConfig() runtime.Config Runtime() runtime.Runtime // Setters. SetRuntime(runtime.Runtime) SetStatus(types.ContainerStatus) }
Interface represents container capabilities.
type ResourceInstance ¶
type ResourceInstance interface {
ToHostConfiguredContainer() (*HostConfiguredContainer, error)
}
ResourceInstance interface represents struct, which can be converted to HostConfiguredContainer.
type RuntimeConfig ¶
RuntimeConfig is a collection of various runtime configurations which can be defined by user.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package resource stores a wrapper over container.Containers, which implements types.Resource interface.
|
Package resource stores a wrapper over container.Containers, which implements types.Resource interface. |
Package runtime provides interfaces describing container runtimes in generic way and their functionality.
|
Package runtime provides interfaces describing container runtimes in generic way and their functionality. |
docker
Package docker implements runtime.Interface and runtime.Config interfaces by talking to Docker API.
|
Package docker implements runtime.Interface and runtime.Config interfaces by talking to Docker API. |
Package types contains types used for managing the containers.
|
Package types contains types used for managing the containers. |