Documentation ¶
Index ¶
- Constants
- func And(left, right map[string][]string) map[string][]string
- func AndString(left, right string) string
- func Convert(c *config.ServiceConfig, ctx project.Context) (*container.Config, *container.HostConfig, error)
- func CreateClient(c ClientOpts) (client.APIClient, error)
- func CreateTar(p *project.Project, name string) (io.ReadCloser, error)
- func Filter(vs []string, f func(string) bool) []string
- func GetContainerByID(client client.APIClient, id string) (*types.Container, error)
- func GetContainerByName(client client.APIClient, name string) (*types.Container, error)
- func GetContainersByFilter(client client.APIClient, containerFilters ...map[string][]string) ([]types.Container, error)
- func NewProject(context *Context) (*project.Project, error)
- type Builder
- type ClientFactory
- type ClientOpts
- type ConfigWrapper
- type Container
- func (c *Container) Create(imageName string) (*types.Container, error)
- func (c *Container) CreateWithOverride(imageName string, configOverride *config.ServiceConfig) (*types.Container, 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) IsRunning() (bool, error)
- func (c *Container) Kill() error
- func (c *Container) Log() error
- func (c *Container) Name() string
- func (c *Container) OutOfSync(imageName string) (bool, error)
- func (c *Container) Pause() error
- func (c *Container) Port(port string) (string, error)
- func (c *Container) Pull() error
- func (c *Container) Recreate(imageName string) (*types.Container, error)
- func (c *Container) Restart() error
- func (c *Container) Run(imageName string, configOverride *config.ServiceConfig) (int, error)
- func (c *Container) Start(container *types.Container) error
- func (c *Container) Stop() error
- func (c *Container) Unpause() 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() *config.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) Pause() error
- func (s *Service) Pull() error
- func (s *Service) Restart() error
- func (s *Service) Run(commandParts []string) (int, error)
- func (s *Service) Scale(scale int) error
- func (s *Service) Start() error
- func (s *Service) Stop() error
- func (s *Service) Unpause() error
- func (s *Service) Up() error
- type ServiceFactory
Constants ¶
const ( NUMBER = Label("com.docker.compose.container-number") ONEOFF = Label("com.docker.compose.oneoff") PROJECT = Label("com.docker.compose.project") SERVICE = Label("com.docker.compose.service") HASH = Label("com.docker.compose.config-hash") VERSION = Label("com.docker.compose.version") )
Libcompose default labels.
const ComposeVersion = "1.5.0"
ComposeVersion is name of docker-compose.yml file syntax supported version
const (
// DefaultAPIVersion is the default docker API version set by libcompose
DefaultAPIVersion = "v1.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 *config.ServiceConfig, ctx project.Context) (*container.Config, *container.HostConfig, error)
Convert converts a service configuration to an docker API structures (Config and HostConfig)
func CreateClient ¶
func CreateClient(c ClientOpts) (client.APIClient, error)
CreateClient creates a docker client based on the specified options.
func GetContainerByID ¶
GetContainerByID looks up the hosts containers with the specified Id and returns it, or an error.
func GetContainerByName ¶
GetContainerByName looks up the hosts containers with the specified name and returns it, or an error.
Types ¶
type Builder ¶
type Builder interface {
Build(imageName string, p *project.Project, service project.Service) error
}
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) client.APIClient }
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/docker/engine-api client.
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 ConfigWrapper ¶ added in v0.2.0
type ConfigWrapper struct { Config *container.Config HostConfig *container.HostConfig NetworkingConfig *network.NetworkingConfig }
ConfigWrapper wraps Config, HostConfig and NetworkingConfig for a container.
func ConvertToAPI ¶
func ConvertToAPI(s *Service) (*ConfigWrapper, error)
ConvertToAPI converts a service configuration to a docker API container configuration.
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 ¶
NewContainer creates a container struct with the specified docker client, name and service.
func (*Container) Create ¶
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) CreateWithOverride ¶ added in v0.2.0
func (c *Container) CreateWithOverride(imageName string, configOverride *config.ServiceConfig) (*types.Container, error)
CreateWithOverride create container and override parts of the config to allow special situations to override the config generated from the compose file
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.
func (*Container) Pause ¶
Pause pauses the container. If the containers are already paused, don't fail.
func (*Container) Recreate ¶
Recreate will not refresh the container by means of relaxation and enjoyment, just delete it and create a new one with the current configuration
func (*Container) Run ¶ added in v0.2.0
Run creates, start and attach to the container based on the image name, the specified configuration. It will always create a new container.
func (*Container) Start ¶ added in v0.2.0
Start the specified container with the specified host config
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(ctx *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 ¶
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 NewService ¶
func NewService(name string, serviceConfig *config.ServiceConfig, context *Context) *Service
NewService creates a service
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() *config.ServiceConfig
Config returns the configuration of the service (config.ServiceConfig).
func (*Service) Containers ¶
Containers implements Service.Containers. It returns the list of containers that are related to the service.
func (*Service) Create ¶
Create implements Service.Create. It ensures the image exists or build it if it can and then create a container.
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 and removes them.
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) Pause ¶
Pause implements Service.Pause. It puts into pause the container(s) related to the service.
func (*Service) Pull ¶
Pull implements Service.Pull. It pulls the image of the service and skip the service that would need to be built.
func (*Service) Restart ¶
Restart implements Service.Restart. It restarts any containers related to the service.
func (*Service) Run ¶ added in v0.2.0
Run implements Service.Run. It runs a one of command within the service container.
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.
func (*Service) Start ¶
Start implements Service.Start. It tries to start a container without creating it.
func (*Service) Stop ¶ added in v0.2.0
Stop implements Service.Stop. It stops any containers related to the service.
type ServiceFactory ¶
type ServiceFactory struct {
// contains filtered or unexported fields
}
ServiceFactory is an implementation of project.ServiceFactory.