Documentation
¶
Index ¶
- Constants
- Variables
- type BuildImageRequest
- type ContainerLink
- type ContainerLinks
- type ContainerLogRequest
- type ContainerPortsRequest
- type ContainerStatusRequest
- type ContainerUnitResponse
- type ContainerUnitResponses
- type ContentRequest
- type DeleteContainerRequest
- type ExtendedBuildImageData
- type InstallContainerRequest
- func (req *InstallContainerRequest) Check() error
- func (req *InstallContainerRequest) Execute(resp JobResponse)
- func (j *InstallContainerRequest) Join(job Job, complete <-chan bool) (joined bool, done <-chan bool, err error)
- func (j *InstallContainerRequest) PortMappingsFrom(pending map[string]interface{}) (port.PortPairs, bool)
- type Job
- type JobContext
- type JobError
- type JobResponse
- type JobResponseFailure
- type JobResponseSuccess
- type Join
- type LabeledJob
- type LinkContainersRequest
- type ListBuildsRequest
- type ListContainersRequest
- type ListContainersResponse
- type ListImagesRequest
- type PatchEnvironmentRequest
- type PutEnvironmentRequest
- type RequestIdentifier
- type RestartContainerRequest
- type RunContainerRequest
- type SimpleJobError
- type StartedContainerStateRequest
- type StoppedContainerStateRequest
- type StructuredJobError
- type UnknownJobError
Constants ¶
const ContentTypeEnvironment = "env"
const PendingPortMappingName = "PortMapping"
Variables ¶
var ( ErrRanToCompletion = SimpleJobError{JobResponseError, "This job has run to completion."} ErrContainerNotFound = SimpleJobError{JobResponseNotFound, "The specified container does not exist."} ErrContainerAlreadyExists = SimpleJobError{JobResponseAlreadyExists, "A container with this identifier already exists."} ErrContainerCreateFailed = SimpleJobError{JobResponseError, "Unable to create container."} ErrContainerStartFailed = SimpleJobError{JobResponseError, "Unable to start this container."} ErrContainerStopFailed = SimpleJobError{JobResponseError, "Unable to stop this container."} ErrContainerRestartFailed = SimpleJobError{JobResponseError, "Unable to restart this container."} ErrEnvironmentNotFound = SimpleJobError{JobResponseNotFound, "Unable to find the requested environment."} ErrEnvironmentUpdateFailed = SimpleJobError{JobResponseError, "Unable to update the specified environment."} ErrListImagesFailed = SimpleJobError{JobResponseError, "Unable to list docker images."} ErrListContainersFailed = SimpleJobError{JobResponseError, "Unable to list the installed containers."} ErrStartRequestThrottled = SimpleJobError{JobResponseRateLimit, "It has been too soon since the last request to start."} ErrStopRequestThrottled = SimpleJobError{JobResponseRateLimit, "It has been too soon since the last request to stop."} ErrRestartRequestThrottled = SimpleJobError{JobResponseRateLimit, "It has been too soon since the last request to restart or the state is currently changing."} ErrLinkContainersFailed = SimpleJobError{JobResponseError, "Not all links could be set."} ErrDeleteContainerFailed = SimpleJobError{JobResponseError, "Unable to delete the container."} ErrContentTypeDoesNotMatch = SimpleJobError{JobResponseNotAcceptable, "The content type you requested is not available for this action."} )
var ErrContainerCreateFailedPortsReserved = SimpleJobError{JobResponseError, "Unable to create container: some ports could not be reserved."}
Functions ¶
This section is empty.
Types ¶
type BuildImageRequest ¶
type BuildImageRequest struct {
*ExtendedBuildImageData
}
func (*BuildImageRequest) Execute ¶
func (j *BuildImageRequest) Execute(resp JobResponse)
type ContainerLink ¶
type ContainerLink struct { Id containers.Identifier NetworkLinks containers.NetworkLinks }
func (*ContainerLink) Check ¶
func (link *ContainerLink) Check() error
type ContainerLinks ¶
type ContainerLinks struct {
Links []ContainerLink
}
func (*ContainerLinks) Check ¶
func (link *ContainerLinks) Check() error
type ContainerLogRequest ¶
type ContainerLogRequest struct {
Id containers.Identifier
}
func (*ContainerLogRequest) Execute ¶
func (j *ContainerLogRequest) Execute(resp JobResponse)
type ContainerPortsRequest ¶
type ContainerPortsRequest struct {
Id containers.Identifier
}
func (*ContainerPortsRequest) Execute ¶
func (j *ContainerPortsRequest) Execute(resp JobResponse)
type ContainerStatusRequest ¶
type ContainerStatusRequest struct {
Id containers.Identifier
}
func (*ContainerStatusRequest) Execute ¶
func (j *ContainerStatusRequest) Execute(resp JobResponse)
type ContainerUnitResponse ¶
type ContainerUnitResponses ¶
type ContainerUnitResponses []ContainerUnitResponse
func (ContainerUnitResponses) Len ¶
func (c ContainerUnitResponses) Len() int
func (ContainerUnitResponses) Less ¶
func (c ContainerUnitResponses) Less(a, b int) bool
func (ContainerUnitResponses) Swap ¶
func (c ContainerUnitResponses) Swap(a, b int)
type ContentRequest ¶
func (*ContentRequest) Execute ¶
func (j *ContentRequest) Execute(resp JobResponse)
func (*ContentRequest) Fast ¶
func (j *ContentRequest) Fast() bool
type DeleteContainerRequest ¶
type DeleteContainerRequest struct {
Id containers.Identifier
}
func (*DeleteContainerRequest) Execute ¶
func (j *DeleteContainerRequest) Execute(resp JobResponse)
type ExtendedBuildImageData ¶
type ExtendedBuildImageData struct { Name string Source string Tag string BaseImage string RuntimeImage string Clean bool Verbose bool }
func (*ExtendedBuildImageData) Check ¶
func (e *ExtendedBuildImageData) Check() error
type InstallContainerRequest ¶
type InstallContainerRequest struct { RequestIdentifier `json:"-"` Id containers.Identifier Image string // A simple container is allowed to default to normal Docker // options like -P. If simple is true no user or home // directory is created and SSH is not available Simple bool // Should this container be run in an isolated fashion // (separate user, permission changes) Isolate bool // Should this container be run in a socket activated fashion // Implies Isolated (separate user, permission changes, // no port forwarding, socket activated). // If UseSocketProxy then socket files are proxies to the // appropriate port SocketActivation bool SkipSocketProxy bool Ports port.PortPairs Environment *containers.EnvironmentDescription NetworkLinks *containers.NetworkLinks // Should the container be started by default Started bool }
Installing a Container
This job will install a given container definition as a systemd service unit, or update the existing definition if one already exists.
There are a number of run modes for containers. Some options the caller must decide:
- Is the container transient? Should stop remove any data not in a volume - accomplished by running as a specific user, and by using 'docker run --rm' as ExecStart=
- Is the container isolated from the rest of the system? Some use cases involve the container having access to the host disk or sockets to perform system roles. Otherwise, where possible containers should be fully isolated from the host via SELinux, user namespaces, and capability dropping.
- Is the container hooked up to other containers? The defined unit should allow regular docker linking (name based pairing), the iptable-based SDN implemented here, and the propagation to the container environment of that configuration (whether as ENV vars or a file).
Isolated containers:
An isolated container runs in a way that protects it from other containers on the system. At a minimum today this means:
- Create a user to represent the container, and run the process in the container as that user. Avoids root compromise
- Assign a unique MCS category label to the container.
In the future the need for #1 is removed by user namespaces, although given the relative immaturity of that function in the kernel at the present time it is not considered sufficiently secure for production use.
func (*InstallContainerRequest) Check ¶
func (req *InstallContainerRequest) Check() error
func (*InstallContainerRequest) Execute ¶
func (req *InstallContainerRequest) Execute(resp JobResponse)
func (*InstallContainerRequest) PortMappingsFrom ¶
func (j *InstallContainerRequest) PortMappingsFrom(pending map[string]interface{}) (port.PortPairs, bool)
type Job ¶
type Job interface {
Execute(JobResponse)
}
type JobContext ¶
type JobContext struct { Id RequestIdentifier User string }
type JobError ¶
type JobError interface { error ResponseFailure() JobResponseFailure ResponseData() interface{} // May be nil if no data is returned to a client }
A structured error response for a job.
type JobResponse ¶
type JobResponse interface { StreamResult() bool Success(t JobResponseSuccess) SuccessWithData(t JobResponseSuccess, data interface{}) SuccessWithWrite(t JobResponseSuccess, flush, structured bool) io.Writer Failure(reason JobError) WriteClosed() <-chan bool WritePendingSuccess(name string, value interface{}) }
A job may return a structured error, a stream of unstructured data, or a stream of structured data. In general, jobs only stream on success - a failure is written immediately. A streaming job may write speculative side channel data that will be returned when a successful response occurs, or thrown away when an error is written. Error writes are final
type JobResponseFailure ¶
type JobResponseFailure int
const ( JobResponseError JobResponseFailure = iota JobResponseAlreadyExists JobResponseNotFound JobResponseInvalidRequest JobResponseRateLimit JobResponseNotAcceptable )
type JobResponseSuccess ¶
type JobResponseSuccess int
const ( JobResponseOk JobResponseSuccess = iota JobResponseAccepted )
type LabeledJob ¶
type LabeledJob interface {
JobLabel() string
}
type LinkContainersRequest ¶
type LinkContainersRequest struct {
*ContainerLinks
}
func (*LinkContainersRequest) Execute ¶
func (j *LinkContainersRequest) Execute(resp JobResponse)
type ListBuildsRequest ¶
type ListBuildsRequest struct { }
func (*ListBuildsRequest) Execute ¶
func (j *ListBuildsRequest) Execute(resp JobResponse)
type ListContainersRequest ¶
type ListContainersRequest struct { }
func (*ListContainersRequest) Execute ¶
func (j *ListContainersRequest) Execute(resp JobResponse)
type ListContainersResponse ¶
type ListContainersResponse struct {
Containers ContainerUnitResponses
}
func (*ListContainersResponse) Append ¶
func (r *ListContainersResponse) Append(other *ListContainersResponse)
func (*ListContainersResponse) Sort ¶
func (r *ListContainersResponse) Sort()
func (*ListContainersResponse) WriteTableTo ¶
func (l *ListContainersResponse) WriteTableTo(w io.Writer) error
type ListImagesRequest ¶
type ListImagesRequest struct {
DockerSocket string
}
func (*ListImagesRequest) Execute ¶
func (j *ListImagesRequest) Execute(resp JobResponse)
type PatchEnvironmentRequest ¶
type PatchEnvironmentRequest struct {
containers.EnvironmentDescription
}
func (*PatchEnvironmentRequest) Execute ¶
func (j *PatchEnvironmentRequest) Execute(resp JobResponse)
type PutEnvironmentRequest ¶
type PutEnvironmentRequest struct {
containers.EnvironmentDescription
}
func (*PutEnvironmentRequest) Execute ¶
func (j *PutEnvironmentRequest) Execute(resp JobResponse)
type RequestIdentifier ¶
type RequestIdentifier []byte
func NewRequestIdentifier ¶
func NewRequestIdentifier() RequestIdentifier
func NewRequestIdentifierFromString ¶
func NewRequestIdentifierFromString(s string) (RequestIdentifier, error)
func (RequestIdentifier) Exact ¶
func (r RequestIdentifier) Exact() string
func (RequestIdentifier) String ¶
func (r RequestIdentifier) String() string
type RestartContainerRequest ¶
type RestartContainerRequest struct {
Id containers.Identifier
}
func (*RestartContainerRequest) Execute ¶
func (j *RestartContainerRequest) Execute(resp JobResponse)
type RunContainerRequest ¶
func (*RunContainerRequest) Check ¶
func (e *RunContainerRequest) Check() error
func (*RunContainerRequest) Execute ¶
func (j *RunContainerRequest) Execute(resp JobResponse)
func (*RunContainerRequest) UnitCommand ¶
func (j *RunContainerRequest) UnitCommand() []string
type SimpleJobError ¶
type SimpleJobError struct { Failure JobResponseFailure Reason string }
An error with a code and message to user
func (SimpleJobError) Error ¶
func (j SimpleJobError) Error() string
func (SimpleJobError) ResponseData ¶
func (j SimpleJobError) ResponseData() interface{}
func (SimpleJobError) ResponseFailure ¶
func (j SimpleJobError) ResponseFailure() JobResponseFailure
type StartedContainerStateRequest ¶
type StartedContainerStateRequest struct {
Id containers.Identifier
}
func (*StartedContainerStateRequest) Execute ¶
func (j *StartedContainerStateRequest) Execute(resp JobResponse)
type StoppedContainerStateRequest ¶
type StoppedContainerStateRequest struct {
Id containers.Identifier
}
func (*StoppedContainerStateRequest) Execute ¶
func (j *StoppedContainerStateRequest) Execute(resp JobResponse)
type StructuredJobError ¶
type StructuredJobError struct { SimpleJobError Data interface{} }
An error that has associated response data to communicate to a client.
func (StructuredJobError) ResponseData ¶
func (j StructuredJobError) ResponseData() interface{}
type UnknownJobError ¶
type UnknownJobError struct {
// contains filtered or unexported fields
}
Cast error to UnknownJobError for default behavior
func (UnknownJobError) ResponseData ¶
func (s UnknownJobError) ResponseData() interface{}
func (UnknownJobError) ResponseFailure ¶
func (s UnknownJobError) ResponseFailure() JobResponseFailure