container

package
v0.10.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildResponse

type BuildResponse struct {
	Stream string `json:"stream"`
	Error  string `json:"error"`
}

BuildResponse is the object that is returned by the docker api in json

type Container added in v0.2.0

type Container interface {
	Build(path string) (tag string, err error)
	CreateNetwork(namespace []string) (id string, err error)
	DeleteNetwork(namespace []string) error
	FindContainer(namespace []string) (types.ContainerJSON, error)
	FindNetwork(namespace []string) (types.NetworkResource, error)
	FindService(namespace []string) (swarm.Service, error)
	ListServices(labels ...string) ([]swarm.Service, error)
	ListTasks(namespace []string) ([]swarm.Task, error)
	Namespace(ss []string) string
	ServiceLogs(namespace []string) (io.ReadCloser, error)
	SharedNetworkID() (networkID string, err error)
	StartService(options ServiceOptions) (serviceID string, err error)
	Status(namespace []string) (StatusType, error)
	StopService(namespace []string) (err error)
	TasksError(namespace []string) ([]string, error)
	DeleteVolume(name string) error
}

Container describes the API of container package.

type DockerContainer added in v0.3.0

type DockerContainer struct {
	// contains filtered or unexported fields
}

DockerContainer provides high level interactions with Docker API for MESG.

func New added in v0.2.0

func New(options ...Option) (*DockerContainer, error)

New creates a new Container with given options.

func (*DockerContainer) Build added in v0.3.0

func (c *DockerContainer) Build(path string) (tag string, err error)

Build builds a docker image.

func (*DockerContainer) CreateNetwork added in v0.3.0

func (c *DockerContainer) CreateNetwork(namespace []string) (id string, err error)

CreateNetwork creates a Docker Network with a namespace.

func (*DockerContainer) DeleteNetwork added in v0.3.0

func (c *DockerContainer) DeleteNetwork(namespace []string) error

DeleteNetwork deletes a Docker Network associated with a namespace.

func (*DockerContainer) DeleteVolume added in v0.5.0

func (c *DockerContainer) DeleteVolume(name string) error

DeleteVolume deletes a Docker Volume by name.

func (*DockerContainer) FindContainer added in v0.3.0

func (c *DockerContainer) FindContainer(namespace []string) (types.ContainerJSON, error)

FindContainer returns a docker container.

func (*DockerContainer) FindNetwork added in v0.3.0

func (c *DockerContainer) FindNetwork(namespace []string) (types.NetworkResource, error)

FindNetwork finds a Docker Network by a namespace. If no network is found, an error is returned.

func (*DockerContainer) FindService added in v0.3.0

func (c *DockerContainer) FindService(namespace []string) (swarm.Service, error)

FindService returns the Docker Service or an error if not found.

func (*DockerContainer) ListServices added in v0.3.0

func (c *DockerContainer) ListServices(labels ...string) ([]swarm.Service, error)

ListServices returns existing docker services matching a specific label name.

func (*DockerContainer) ListTasks added in v0.3.0

func (c *DockerContainer) ListTasks(namespace []string) ([]swarm.Task, error)

ListTasks returns all the docker tasks.

func (*DockerContainer) Namespace added in v0.3.0

func (c *DockerContainer) Namespace(ss []string) string

Namespace creates a namespace from a list of string.

func (*DockerContainer) ServiceLogs added in v0.3.0

func (c *DockerContainer) ServiceLogs(namespace []string) (io.ReadCloser, error)

ServiceLogs returns the logs of a service.

func (*DockerContainer) SharedNetworkID added in v0.3.0

func (c *DockerContainer) SharedNetworkID() (networkID string, err error)

SharedNetworkID returns the ID of the shared network.

func (*DockerContainer) StartService added in v0.3.0

func (c *DockerContainer) StartService(options ServiceOptions) (serviceID string, err error)

StartService starts a docker service.

func (*DockerContainer) Status added in v0.3.0

func (c *DockerContainer) Status(namespace []string) (StatusType, error)

Status returns the status of the container based on the docker container and docker service. if any error occurs during the status check, status will be shown as UNKNOWN. otherwise the following rules will be applied to determine a status:

  • RUNNING: when the container is running in docker regardless of the status of the service.
  • STARTING: when the service is running but the container is not yet started.
  • STOPPED: when the container and the service is not running in docker.

func (*DockerContainer) StopService added in v0.3.0

func (c *DockerContainer) StopService(namespace []string) error

StopService stops a docker service.

func (*DockerContainer) TasksError added in v0.3.0

func (c *DockerContainer) TasksError(namespace []string) ([]string, error)

TasksError returns the error of matching tasks.

type Mount

type Mount struct {
	Source string
	Target string
	Bind   bool
}

Mount is a simplify version of mount.Mount.

type Network added in v0.4.0

type Network struct {
	// ID of the docker network.
	ID string

	// Alias is an optional attribute to name this service in the
	// network and be able to access to it using this name.
	Alias string
}

Network keeps the network info for service.

type Option added in v0.2.0

type Option func(*DockerContainer)

Option is a configuration func for Container.

func ClientOption added in v0.2.0

func ClientOption(client docker.CommonAPIClient) Option

ClientOption receives a client which will be used to interact with Docker API.

func TimeoutOption added in v0.2.0

func TimeoutOption(d time.Duration) Option

TimeoutOption receives d which will be set as a timeout value for Docker API calls.

type Port

type Port struct {
	Target    uint32
	Published uint32
}

Port is a simplify version of swarm.PortConfig.

type ServiceOptions

type ServiceOptions struct {
	Image           string
	Namespace       []string
	Ports           []Port
	Mounts          []Mount
	Env             []string // TODO: should be transform to  map[string]string and use the func mapToEnv
	Args            []string
	Command         string
	Networks        []Network
	Labels          map[string]string
	StopGracePeriod *time.Duration
}

ServiceOptions is a simplify version of swarm.ServiceSpec.

type StatusType

type StatusType uint

StatusType of the service.

const (
	UNKNOWN StatusType = iota
	STOPPED
	STARTING
	RUNNING
)

Possible status for services.

Directories

Path Synopsis
Package dockertest provides functionalities for mocking and faking the Docker API.
Package dockertest provides functionalities for mocking and faking the Docker API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL