Documentation ¶
Index ¶
- Constants
- Variables
- func GetContainerFromIpcLikeConfig(p *Project, conf string) string
- func NameAlias(name string) (string, string)
- func NewDefaultListener(p *Project) chan<- events.Event
- type APIProject
- type ClientFactory
- type Container
- type Context
- type EmptyService
- func (e *EmptyService) Build(ctx context.Context, buildOptions options.Build) error
- func (e *EmptyService) Containers(ctx context.Context) ([]Container, error)
- func (e *EmptyService) Create(ctx context.Context, options options.Create) error
- func (e *EmptyService) Delete(ctx context.Context, options options.Delete) error
- func (e *EmptyService) Info(ctx context.Context, qFlag bool) (InfoSet, error)
- func (e *EmptyService) Kill(ctx context.Context, signal string) error
- func (e *EmptyService) Log(ctx context.Context, follow bool) error
- func (e *EmptyService) Pause(ctx context.Context) error
- func (e *EmptyService) Pull(ctx context.Context) error
- func (e *EmptyService) RemoveImage(ctx context.Context, imageType options.ImageType) error
- func (e *EmptyService) Restart(ctx context.Context, timeout int) error
- func (e *EmptyService) Run(ctx context.Context, commandParts []string) (int, error)
- func (e *EmptyService) Scale(ctx context.Context, count int, timeout int) error
- func (e *EmptyService) Start(ctx context.Context) error
- func (e *EmptyService) Stop(ctx context.Context, timeout int) error
- func (e *EmptyService) Unpause(ctx context.Context) error
- func (e *EmptyService) Up(ctx context.Context, options options.Up) error
- type Info
- type InfoPart
- type InfoSet
- type Project
- func (p *Project) AddConfig(name string, config *config.ServiceConfig) error
- func (p *Project) AddListener(c chan<- events.Event)
- func (p *Project) AddNetworkConfig(name string, config *config.NetworkConfig) error
- func (p *Project) AddVolumeConfig(name string, config *config.VolumeConfig) error
- func (p *Project) Build(ctx context.Context, buildOptions options.Build, services ...string) error
- func (p *Project) Create(ctx context.Context, options options.Create, services ...string) error
- func (p *Project) CreateService(name string) (Service, error)
- func (p *Project) Delete(ctx context.Context, options options.Delete, services ...string) error
- func (p *Project) Down(ctx context.Context, opts options.Down, services ...string) error
- func (p *Project) Kill(ctx context.Context, signal string, services ...string) error
- func (p *Project) Load(bytes []byte) error
- func (p *Project) Log(ctx context.Context, follow bool, services ...string) error
- func (p *Project) Notify(eventType events.EventType, serviceName string, data map[string]string)
- func (p *Project) Parse() error
- func (p *Project) Pause(ctx context.Context, services ...string) error
- func (p *Project) Port(ctx context.Context, index int, protocol, serviceName, privatePort string) (string, error)
- func (p *Project) Ps(ctx context.Context, onlyID bool, services ...string) (InfoSet, error)
- func (p *Project) Pull(ctx context.Context, services ...string) error
- func (p *Project) Restart(ctx context.Context, timeout int, services ...string) error
- func (p *Project) Run(ctx context.Context, serviceName string, commandParts []string) (int, error)
- func (p *Project) Scale(ctx context.Context, timeout int, servicesScale map[string]int) error
- func (p *Project) Start(ctx context.Context, services ...string) error
- func (p *Project) Stop(ctx context.Context, timeout int, services ...string) error
- func (p *Project) Unpause(ctx context.Context, services ...string) error
- func (p *Project) Up(ctx context.Context, options options.Up, services ...string) error
- type Service
- type ServiceFactory
- type ServiceRelationship
- type ServiceRelationshipType
- type ServiceState
Constants ¶
const RelTypeDependsOn = ServiceRelationshipType("dependsOn")
RelTypeDependsOn means the dependency was explicitly set using 'depends_on'.
const RelTypeIpcNamespace = ServiceRelationshipType("ipc")
RelTypeIpcNamespace means the service share the same ipc namespace.
const RelTypeLink = ServiceRelationshipType("")
RelTypeLink means the services are linked (docker links).
const RelTypeNetNamespace = ServiceRelationshipType("netns")
RelTypeNetNamespace means the services share the same network namespace.
const RelTypeVolumesFrom = ServiceRelationshipType("volumesFrom")
RelTypeVolumesFrom means the services share some volumes.
Variables ¶
var ( StateExecuted = ServiceState("executed") StateUnknown = ServiceState("unknown") )
State definitions
var ( ErrRestart = errors.New("Restart execution") ErrUnsupported = errors.New("UnsupportedOperation") )
Error definitions
Functions ¶
func GetContainerFromIpcLikeConfig ¶
GetContainerFromIpcLikeConfig returns name of the service that shares the IPC namespace with the specified service.
func NameAlias ¶
NameAlias returns the name and alias based on the specified string. If the name contains a colon (like name:alias) it will split it, otherwise it will return the specified name as name and alias.
func NewDefaultListener ¶
NewDefaultListener create a default listener for the specified project.
Types ¶
type APIProject ¶
type APIProject interface { events.Notifier events.Emitter Build(ctx context.Context, options options.Build, sevice ...string) error Create(ctx context.Context, options options.Create, services ...string) error Delete(ctx context.Context, options options.Delete, services ...string) error Down(ctx context.Context, options options.Down, services ...string) error Kill(ctx context.Context, signal string, services ...string) error Log(ctx context.Context, follow bool, services ...string) error Pause(ctx context.Context, services ...string) error Ps(ctx context.Context, onlyID bool, services ...string) (InfoSet, error) // FIXME(vdemeester) we could use nat.Port instead ? Port(ctx context.Context, index int, protocol, serviceName, privatePort string) (string, error) Pull(ctx context.Context, services ...string) error Restart(ctx context.Context, timeout int, services ...string) error Run(ctx context.Context, serviceName string, commandParts []string) (int, error) Scale(ctx context.Context, timeout int, servicesScale map[string]int) error Start(ctx context.Context, services ...string) error Stop(ctx context.Context, timeout int, services ...string) error Unpause(ctx context.Context, services ...string) error Up(ctx context.Context, options options.Up, services ...string) error Parse() error CreateService(name string) (Service, error) AddConfig(name string, config *config.ServiceConfig) error Load(bytes []byte) error }
APIProject is an interface defining the methods a libcompose project should implement.
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 Service) client.APIClient }
ClientFactory is a factory to create docker clients.
func NewDefaultClientFactory ¶
func NewDefaultClientFactory(opts composeclient.Options) (ClientFactory, error)
NewDefaultClientFactory creates and returns the default client factory that uses github.com/docker/engine-api client.
type Container ¶
type Container interface { ID() (string, error) Name() string Port(ctx context.Context, port string) (string, error) IsRunning(ctx context.Context) (bool, error) }
Container defines what a libcompose container provides.
type Context ¶
type Context struct { ComposeFiles []string ComposeBytes [][]byte ProjectName string ServiceFactory ServiceFactory EnvironmentLookup config.EnvironmentLookup ResourceLookup config.ResourceLookup LoggerFactory logger.Factory IgnoreMissingConfig bool Project *Project // contains filtered or unexported fields }
Context holds context meta information about a libcompose project, like the project name, the compose file, etc.
type EmptyService ¶
type EmptyService struct { }
EmptyService is a struct that implements Service but does nothing.
func (*EmptyService) Containers ¶
func (e *EmptyService) Containers(ctx context.Context) ([]Container, error)
Containers implements Service.Containers but does nothing.
func (*EmptyService) Kill ¶
func (e *EmptyService) Kill(ctx context.Context, signal string) error
Kill implements Service.Kill but does nothing.
func (*EmptyService) Log ¶
func (e *EmptyService) Log(ctx context.Context, follow bool) error
Log implements Service.Log but does nothing.
func (*EmptyService) Pause ¶
func (e *EmptyService) Pause(ctx context.Context) error
Pause implements Service.Pause but does nothing.
func (*EmptyService) Pull ¶
func (e *EmptyService) Pull(ctx context.Context) error
Pull implements Service.Pull but does nothing.
func (*EmptyService) RemoveImage ¶
RemoveImage implements Service.RemoveImage but does nothing.
func (*EmptyService) Restart ¶
func (e *EmptyService) Restart(ctx context.Context, timeout int) error
Restart implements Service.Restart but does nothing.
func (*EmptyService) Start ¶
func (e *EmptyService) Start(ctx context.Context) error
Start implements Service.Start but does nothing.
func (*EmptyService) Stop ¶
func (e *EmptyService) Stop(ctx context.Context, timeout int) error
Stop implements Service.Stop() but does nothing.
type Project ¶
type Project struct { Name string ServiceConfigs *config.ServiceConfigs VolumeConfigs map[string]*config.VolumeConfig NetworkConfigs map[string]*config.NetworkConfig Files []string ReloadCallback func() error ParseOptions *config.ParseOptions // contains filtered or unexported fields }
Project holds libcompose project information.
func NewProject ¶
func NewProject(clientFactory ClientFactory, context *Context, parseOptions *config.ParseOptions) *Project
NewProject creates a new project with the specified context.
func (*Project) AddConfig ¶
func (p *Project) AddConfig(name string, config *config.ServiceConfig) error
AddConfig adds the specified service config for the specified name.
func (*Project) AddListener ¶
AddListener adds the specified listener to the project. This implements implicitly events.Emitter.
func (*Project) AddNetworkConfig ¶
func (p *Project) AddNetworkConfig(name string, config *config.NetworkConfig) error
AddNetworkConfig adds the specified network config for the specified name.
func (*Project) AddVolumeConfig ¶
func (p *Project) AddVolumeConfig(name string, config *config.VolumeConfig) error
AddVolumeConfig adds the specified volume config for the specified name.
func (*Project) CreateService ¶
CreateService creates a service with the specified name based. If there is no config in the project for this service, it will return an error.
func (*Project) Down ¶
Down stops the specified services and clean related containers (like docker stop + docker rm).
func (*Project) Load ¶
Load loads the specified byte array (the composefile content) and adds the service configuration to the project. FIXME is it needed ?
func (*Project) Notify ¶
Notify notifies all project listener with the specified eventType, service name and datas. This implements implicitly events.Notifier interface.
func (*Project) Parse ¶
Parse populates project information based on its context. It sets up the name, the composefile and the composebytes (the composefile content).
func (*Project) Port ¶
func (p *Project) Port(ctx context.Context, index int, protocol, serviceName, privatePort string) (string, error)
Port returns the public port for a port binding of the specified service.
type Service ¶
type Service interface { Build(ctx context.Context, buildOptions options.Build) error Create(ctx context.Context, options options.Create) error Delete(ctx context.Context, options options.Delete) error Info(ctx context.Context, qFlag bool) (InfoSet, error) Log(ctx context.Context, follow bool) error Kill(ctx context.Context, signal string) error Pause(ctx context.Context) error Pull(ctx context.Context) error Restart(ctx context.Context, timeout int) error Run(ctx context.Context, commandParts []string) (int, error) Scale(ctx context.Context, count int, timeout int) error Start(ctx context.Context) error Stop(ctx context.Context, timeout int) error Unpause(ctx context.Context) error Up(ctx context.Context, options options.Up) error RemoveImage(ctx context.Context, imageType options.ImageType) error Containers(ctx context.Context) ([]Container, error) DependentServices() []ServiceRelationship Config() *config.ServiceConfig Name() string }
Service defines what a libcompose service provides.
type ServiceFactory ¶
type ServiceFactory interface {
Create(project *Project, name string, serviceConfig *config.ServiceConfig) (Service, error)
}
ServiceFactory is an interface factory to create Service object for the specified project, with the specified name and service configuration.
type ServiceRelationship ¶
type ServiceRelationship struct {
Target, Alias string
Type ServiceRelationshipType
Optional bool
}
ServiceRelationship holds the relationship information between two services.
func DefaultDependentServices ¶
func DefaultDependentServices(p *Project, s Service) []ServiceRelationship
DefaultDependentServices return the dependent services (as an array of ServiceRelationship) for the specified project and service. It looks for : links, volumesFrom, net and ipc configuration.
func NewServiceRelationship ¶
func NewServiceRelationship(nameAlias string, relType ServiceRelationshipType) ServiceRelationship
NewServiceRelationship creates a new Relationship based on the specified alias and relationship type.
type ServiceRelationshipType ¶
type ServiceRelationshipType string
ServiceRelationshipType defines the type of service relationship.