Documentation ¶
Index ¶
- Constants
- func And(left, right map[string][]string) map[string][]string
- func AndString(left, right string) string
- func Convert(c *project.ServiceConfig) (*dockerclient.Config, *dockerclient.HostConfig, error)
- func ConvertToAPI(c *project.ServiceConfig, name string) (*dockerclient.CreateContainerOptions, error)
- func CreateClient(c ClientOpts) (*dockerclient.Client, error)
- func CreateTar(p *project.Project, name string) (io.ReadCloser, error)
- func Filter(vs []string, f func(string) bool) []string
- func GetContainerByName(client *dockerclient.Client, name string) (*dockerclient.APIContainers, error)
- func GetContainersByFilter(client *dockerclient.Client, filters ...map[string][]string) ([]dockerclient.APIContainers, error)
- func NewProject(context *Context) (*project.Project, error)
- type Builder
- type ClientFactory
- type ClientOpts
- type Container
- func (c *Container) Create(imageName string) (*dockerclient.APIContainers, error)
- func (c *Container) Delete() error
- func (c *Container) Down() error
- func (c *Container) ID() (string, error)
- func (c *Container) Info(qFlag bool) (project.Info, error)
- func (c *Container) Kill() error
- func (c *Container) Log() error
- func (c *Container) Name() string
- func (c *Container) OutOfSync() (bool, error)
- func (c *Container) Port(port string) (string, error)
- func (c *Container) Pull() error
- func (c *Container) Restart() error
- func (c *Container) Up(imageName string) error
- type Context
- type DaemonBuilder
- type Label
- type Namer
- type Service
- func (s *Service) Build() error
- func (s *Service) Config() *project.ServiceConfig
- func (s *Service) Containers() ([]project.Container, error)
- func (s *Service) Create() error
- func (s *Service) Delete() error
- func (s *Service) DependentServices() []project.ServiceRelationship
- func (s *Service) Down() error
- func (s *Service) Info(qFlag bool) (project.InfoSet, error)
- func (s *Service) Kill() error
- func (s *Service) Log() error
- func (s *Service) Name() string
- func (s *Service) Pull() error
- func (s *Service) Restart() error
- func (s *Service) Scale(scale int) error
- func (s *Service) Start() error
- func (s *Service) Up() error
- type ServiceFactory
Constants ¶
const ( NAME = Label("io.docker.compose.name") PROJECT = Label("io.docker.compose.project") SERVICE = Label("io.docker.compose.service") HASH = Label("io.docker.compose.config-hash") )
Libcompose default labels.
const (
// DefaultAPIVersion is the default docker API version set by libcompose
DefaultAPIVersion = "1.20"
)
const DefaultDockerfileName = "Dockerfile"
DefaultDockerfileName is the default name of a Dockerfile
const DefaultTag = "latest"
DefaultTag is the name of the default tag of an image.
Variables ¶
This section is empty.
Functions ¶
func AndString ¶
AndString returns a json list of labels by merging the two specified values (left and right) serialized as string.
func Convert ¶
func Convert(c *project.ServiceConfig) (*dockerclient.Config, *dockerclient.HostConfig, error)
Convert converts a service configuration to an docker API structures (Config and HostConfig)
func ConvertToAPI ¶
func ConvertToAPI(c *project.ServiceConfig, name string) (*dockerclient.CreateContainerOptions, error)
ConvertToAPI converts a service configuration to a docker API container configuration.
func CreateClient ¶
func CreateClient(c ClientOpts) (*dockerclient.Client, error)
CreateClient creates a docker client based on the specified options.
func GetContainerByName ¶
func GetContainerByName(client *dockerclient.Client, name string) (*dockerclient.APIContainers, error)
GetContainerByName looks up the hosts containers with the specified name and returns it, or an error.
func GetContainersByFilter ¶
func GetContainersByFilter(client *dockerclient.Client, filters ...map[string][]string) ([]dockerclient.APIContainers, error)
GetContainersByFilter looks up the hosts containers with the specified filters and returns a list of container matching it, or an error.
Types ¶
type Builder ¶
Builder defines methods to provide a docker builder. This makes libcompose not tied up to the docker daemon builder.
type ClientFactory ¶
type ClientFactory interface { // Create constructs a Docker client for the given service. The passed in // config may be nil in which case a generic client for the project should // be returned. Create(service project.Service) *dockerclient.Client }
ClientFactory is a factory to create docker clients.
func NewDefaultClientFactory ¶
func NewDefaultClientFactory(opts ClientOpts) (ClientFactory, error)
NewDefaultClientFactory creates and returns the default client factory that uses github.com/samalba/dockerclient.
type ClientOpts ¶
type ClientOpts struct { TLS bool TLSVerify bool TLSOptions tlsconfig.Options TrustKey string Host string APIVersion string }
ClientOpts holds docker client options (host, tls, ..)
type Container ¶
type Container struct { project.EmptyService // contains filtered or unexported fields }
Container holds information about a docker container and the service it is tied on. It implements Service interface by encapsulating a EmptyService.
func NewContainer ¶
func NewContainer(client *dockerclient.Client, name string, service *Service) *Container
NewContainer creates a container struct with the specified docker client, name and service.
func (*Container) Create ¶
func (c *Container) Create(imageName string) (*dockerclient.APIContainers, error)
Create creates the container based on the specified image name and send an event to notify the container has been created. If the container already exists, does nothing.
func (*Container) Delete ¶
Delete removes the container if existing. If the container is running, it tries to stop it first.
func (*Container) OutOfSync ¶
OutOfSync checks if the container is out of sync with the service definition. It looks if the the service hash container label is the same as the computed one.
type Context ¶
type Context struct { project.Context Builder Builder ClientFactory ClientFactory ConfigDir string ConfigFile *cliconfig.ConfigFile }
Context holds context meta information about a libcompose project and docker client information (like configuration file, builder to use, …)
func (*Context) LookupConfig ¶
LookupConfig tries to load the docker configuration files, if any.
type DaemonBuilder ¶
type DaemonBuilder struct {
// contains filtered or unexported fields
}
DaemonBuilder is the daemon "docker build" Builder implementation.
func NewDaemonBuilder ¶
func NewDaemonBuilder(context *Context) *DaemonBuilder
NewDaemonBuilder creates a DaemonBuilder based on the specified context.
type Label ¶
type Label string
Label represents a docker label.
type Namer ¶
Namer defines method to provide container name.
func NewNamer ¶
func NewNamer(client *dockerclient.Client, project, service string) Namer
NewNamer returns a namer that returns names based on the specified project and service name and an inner counter, e.g. project_service_1, project_service_2…
func NewSingleNamer ¶
NewSingleNamer returns a namer that only allows a single name.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is a project.Service implementations.
func (*Service) Build ¶
Build implements Service.Build. If an imageName is specified or if the context has no build to work with it will do nothing. Otherwise it will try to build the image and returns an error if any.
func (*Service) Config ¶
func (s *Service) Config() *project.ServiceConfig
Config returns the configuration of the service (project.ServiceConfig).
func (*Service) Containers ¶
Containers implements Service.Containers. It returns the list of containers that are related to the service.
func (*Service) Delete ¶
Delete implements Service.Delete. It removes any containers related to the service.
func (*Service) DependentServices ¶
func (s *Service) DependentServices() []project.ServiceRelationship
DependentServices returns the dependent services (as an array of ServiceRelationship) of the service.
func (*Service) Down ¶
Down implements Service.Down. It stops any containers related to the service.
func (*Service) Info ¶
Info implements Service.Info. It returns an project.InfoSet with the containers related to this service (can be multiple if using the scale command).
func (*Service) Kill ¶
Kill implements Service.Kill. It kills any containers related to the service.
func (*Service) Log ¶
Log implements Service.Log. It returns the docker logs for each container related to the service.
func (*Service) Restart ¶
Restart implements Service.Restart. It restarts any containers related to the service.
func (*Service) Scale ¶
Scale implements Service.Scale. It creates or removes containers to have the specified number of related container to the service to run.
type ServiceFactory ¶
type ServiceFactory struct {
// contains filtered or unexported fields
}
ServiceFactory is an implementation of project.ServiceFactory.