Documentation ¶
Index ¶
- Constants
- func Convert(c *config.ServiceConfig, ctx project.Context) (*container.Config, *container.HostConfig, error)
- func Filter(vs []string, f func(string) bool) []string
- func GetContainer(ctx context.Context, clientInstance client.APIClient, id string) (*types.ContainerJSON, error)
- func GetContainersByFilter(ctx context.Context, clientInstance client.APIClient, ...) ([]types.Container, error)
- func NewProject(context *Context, parseOptions *config.ParseOptions) (*project.Project, error)
- type AuthLookup
- type ConfigAuthLookup
- type ConfigWrapper
- type Container
- func (c *Container) Create(ctx context.Context, imageName string) (*types.ContainerJSON, error)
- func (c *Container) CreateWithOverride(ctx context.Context, imageName string, configOverride *config.ServiceConfig) (*types.ContainerJSON, error)
- func (c *Container) Delete(ctx context.Context, removeVolume bool) error
- func (c *Container) ID() (string, error)
- func (c *Container) Info(ctx context.Context, qFlag bool) (project.Info, error)
- func (c *Container) IsRunning(ctx context.Context) (bool, error)
- func (c *Container) Kill(ctx context.Context, signal string) error
- func (c *Container) Log(ctx context.Context, follow bool) error
- func (c *Container) Name() string
- func (c *Container) OutOfSync(ctx context.Context, imageName string) (bool, error)
- func (c *Container) Pause(ctx context.Context) error
- func (c *Container) Port(ctx context.Context, port string) (string, error)
- func (c *Container) Recreate(ctx context.Context, imageName string) (*types.ContainerJSON, error)
- func (c *Container) Restart(ctx context.Context, timeout int) error
- func (c *Container) Run(ctx context.Context, imageName string, configOverride *config.ServiceConfig) (int, error)
- func (c *Container) Start(container *types.ContainerJSON) error
- func (c *Container) Stop(ctx context.Context, timeout int) error
- func (c *Container) Unpause(ctx context.Context) error
- func (c *Container) Up(ctx context.Context, imageName string) error
- type Context
- type Namer
- type Service
- func (s *Service) Build(ctx context.Context, buildOptions options.Build) error
- func (s *Service) Config() *config.ServiceConfig
- func (s *Service) Containers(ctx context.Context) ([]project.Container, error)
- func (s *Service) Create(ctx context.Context, options options.Create) error
- func (s *Service) Delete(ctx context.Context, options options.Delete) error
- func (s *Service) DependentServices() []project.ServiceRelationship
- func (s *Service) Info(ctx context.Context, qFlag bool) (project.InfoSet, error)
- func (s *Service) Kill(ctx context.Context, signal string) error
- func (s *Service) Log(ctx context.Context, follow bool) error
- func (s *Service) Name() string
- func (s *Service) NetworkConnect(ctx context.Context, c *Container, net, ipv4 string, oneOff bool) error
- func (s *Service) NetworkDisconnect(ctx context.Context, c *Container, net string, oneOff bool) error
- func (s *Service) Pause(ctx context.Context) error
- func (s *Service) Pull(ctx context.Context) error
- func (s *Service) RemoveImage(ctx context.Context, imageType options.ImageType) error
- func (s *Service) Restart(ctx context.Context, timeout int) error
- func (s *Service) Run(ctx context.Context, commandParts []string) (int, error)
- func (s *Service) Scale(ctx context.Context, scale int, timeout int) error
- func (s *Service) Start(ctx context.Context) error
- func (s *Service) Stop(ctx context.Context, timeout int) error
- func (s *Service) Unpause(ctx context.Context) error
- func (s *Service) Up(ctx context.Context, options options.Up) error
- type ServiceFactory
Constants ¶
const ComposeVersion = "1.5.0"
ComposeVersion is name of docker-compose.yml file syntax supported version
Variables ¶
This section is empty.
Functions ¶
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 GetContainer ¶
func GetContainer(ctx context.Context, clientInstance client.APIClient, id string) (*types.ContainerJSON, error)
GetContainer looks up the hosts containers with the specified ID or name and returns it, or an error.
func GetContainersByFilter ¶
func GetContainersByFilter(ctx context.Context, clientInstance client.APIClient, containerFilters ...map[string][]string) ([]types.Container, error)
GetContainersByFilter looks up the hosts containers with the specified filters and returns a list of container matching it, or an error.
func NewProject ¶
NewProject creates a Project with the specified context.
Types ¶
type AuthLookup ¶
type AuthLookup interface { All() map[string]types.AuthConfig Lookup(repoInfo *registry.RepositoryInfo) types.AuthConfig }
AuthLookup defines a method for looking up authentication information
type ConfigAuthLookup ¶
type ConfigAuthLookup struct {
// contains filtered or unexported fields
}
ConfigAuthLookup implements AuthLookup by reading a Docker config file
func NewConfigAuthLookup ¶
func NewConfigAuthLookup(context *Context) *ConfigAuthLookup
NewConfigAuthLookup creates a new ConfigAuthLookup for a given context
func (*ConfigAuthLookup) All ¶
func (c *ConfigAuthLookup) All() map[string]types.AuthConfig
All uses a Docker config file to get all authentication information
func (*ConfigAuthLookup) Lookup ¶
func (c *ConfigAuthLookup) Lookup(repoInfo *registry.RepositoryInfo) types.AuthConfig
Lookup uses a Docker config file to lookup authentication information
type ConfigWrapper ¶
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 {
// contains filtered or unexported fields
}
Container holds information about a docker container and the service it is tied on.
func NewContainer ¶
func NewContainer(client client.APIClient, name string, containerNumber int, service *Service) *Container
NewContainer creates a container struct with the specified docker client, name and service.
func NewOneOffContainer ¶
func NewOneOffContainer(client client.APIClient, name string, containerNumber int, service *Service) *Container
NewOneOffContainer creates a "oneoff" 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 ¶
func (c *Container) CreateWithOverride(ctx context.Context, imageName string, configOverride *config.ServiceConfig) (*types.ContainerJSON, 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 ¶
func (c *Container) Run(ctx context.Context, imageName string, configOverride *config.ServiceConfig) (int, error)
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 ¶
func (c *Container) Start(container *types.ContainerJSON) error
Start the specified container with the specified host config
type Context ¶
type Context struct { project.Context ClientFactory project.ClientFactory ConfigDir string ConfigFile *cliconfig.ConfigFile AuthLookup AuthLookup }
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 Namer ¶
Namer defines method to provide container name.
func NewNamer ¶
func NewNamer(ctx context.Context, client client.APIClient, project, service string, oneOff bool) (Namer, error)
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) 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) NetworkConnect ¶
func (s *Service) NetworkConnect(ctx context.Context, c *Container, net, ipv4 string, oneOff bool) error
NetworkConnect connects the container to the specified network FIXME(vdemeester) will be refactor with Container refactoring
func (*Service) NetworkDisconnect ¶
func (s *Service) NetworkDisconnect(ctx context.Context, c *Container, net string, oneOff bool) error
NetworkDisconnect disconnects the container from the specified network
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) RemoveImage ¶
RemoveImage implements Service.RemoveImage. It removes images used for the service depending on the specified type.
func (*Service) Restart ¶
Restart implements Service.Restart. It restarts any containers related to the service.
func (*Service) Run ¶
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 ¶
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.