libcompose: github.com/docker/libcompose/project Index | Files | Directories

package project

import "github.com/docker/libcompose/project"

Index

Package Files

container.go context.go empty.go info.go interface.go listener.go network.go project.go project_build.go project_config.go project_containers.go project_create.go project_delete.go project_down.go project_events.go project_kill.go project_log.go project_pause.go project_port.go project_ps.go project_pull.go project_restart.go project_run.go project_scale.go project_start.go project_stop.go project_unpause.go project_up.go service-wrapper.go service.go utils.go volume.go

Constants

const (
    AnyState = State("")
    Running  = State("running")
    Stopped  = State("stopped")
)

Definitions of filter states

const ComposeVersion = "1.5.0"

ComposeVersion is name of docker-compose.yml file syntax supported version

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 RelTypeNetworkMode = ServiceRelationshipType("networkMode")

RelTypeNetworkMode means the services depends on another service on networkMode

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

func DefaultDependentServices Uses

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 IsNamedVolume Uses

func IsNamedVolume(volume string) bool

IsNamedVolume returns whether the specified volume (string) is a named volume or not.

func NameAlias Uses

func NameAlias(name string) (string, string)

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 Uses

func NewDefaultListener(p *Project) chan<- events.Event

NewDefaultListener create a default listener for the specified project.

type APIProject Uses

type APIProject interface {
    events.Notifier
    events.Emitter

    Build(ctx context.Context, options options.Build, sevice ...string) error
    Config() (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
    Events(ctx context.Context, services ...string) (chan events.ContainerEvent, 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, 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, options options.Run) (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
    Containers(ctx context.Context, filter Filter, services ...string) ([]string, error)

    GetServiceConfig(service string) (*config.ServiceConfig, bool)
}

APIProject defines the methods a libcompose project should implement.

type Container Uses

type Container interface {
    ID() string
    Name() string
    Port(ctx context.Context, port string) (string, error)
    IsRunning(ctx context.Context) bool
}

Container defines what a libcompose container provides.

type Context Uses

type Context struct {
    ComposeFiles []string
    ComposeBytes [][]byte
    ProjectName  string

    ServiceFactory      ServiceFactory
    NetworksFactory     NetworksFactory
    VolumesFactory      VolumesFactory
    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 EmptyNetworks Uses

type EmptyNetworks struct {
}

EmptyNetworks is a struct that implements Networks but does nothing.

func (*EmptyNetworks) Initialize Uses

func (e *EmptyNetworks) Initialize(ctx context.Context) error

Initialize implements Networks.Initialize but does nothing.

func (*EmptyNetworks) Remove Uses

func (e *EmptyNetworks) Remove(ctx context.Context) error

Remove implements Networks.Remove but does nothing.

type EmptyService Uses

type EmptyService struct {
}

EmptyService is a struct that implements Service but does nothing.

func (*EmptyService) Build Uses

func (e *EmptyService) Build(ctx context.Context, buildOptions options.Build) error

Build implements Service.Build but does nothing.

func (*EmptyService) Config Uses

func (e *EmptyService) Config() *config.ServiceConfig

Config implements Service.Config with empty config.

func (*EmptyService) Containers Uses

func (e *EmptyService) Containers(ctx context.Context) ([]Container, error)

Containers implements Service.Containers but does nothing.

func (*EmptyService) Create Uses

func (e *EmptyService) Create(ctx context.Context, options options.Create) error

Create implements Service.Create but does nothing.

func (*EmptyService) Delete Uses

func (e *EmptyService) Delete(ctx context.Context, options options.Delete) error

Delete implements Service.Delete but does nothing.

func (*EmptyService) DependentServices Uses

func (e *EmptyService) DependentServices() []ServiceRelationship

DependentServices implements Service.DependentServices with empty slice.

func (*EmptyService) Events Uses

func (e *EmptyService) Events(ctx context.Context, events chan events.ContainerEvent) error

Events implements Service.Events but does nothing.

func (*EmptyService) Info Uses

func (e *EmptyService) Info(ctx context.Context) (InfoSet, error)

Info implements Service.Info but does nothing.

func (*EmptyService) Kill Uses

func (e *EmptyService) Kill(ctx context.Context, signal string) error

Kill implements Service.Kill but does nothing.

func (*EmptyService) Log Uses

func (e *EmptyService) Log(ctx context.Context, follow bool) error

Log implements Service.Log but does nothing.

func (*EmptyService) Name Uses

func (e *EmptyService) Name() string

Name implements Service.Name with empty name.

func (*EmptyService) Pause Uses

func (e *EmptyService) Pause(ctx context.Context) error

Pause implements Service.Pause but does nothing.

func (*EmptyService) Pull Uses

func (e *EmptyService) Pull(ctx context.Context) error

Pull implements Service.Pull but does nothing.

func (*EmptyService) RemoveImage Uses

func (e *EmptyService) RemoveImage(ctx context.Context, imageType options.ImageType) error

RemoveImage implements Service.RemoveImage but does nothing.

func (*EmptyService) Restart Uses

func (e *EmptyService) Restart(ctx context.Context, timeout int) error

Restart implements Service.Restart but does nothing.

func (*EmptyService) Run Uses

func (e *EmptyService) Run(ctx context.Context, commandParts []string, options options.Run) (int, error)

Run implements Service.Run but does nothing.

func (*EmptyService) Scale Uses

func (e *EmptyService) Scale(ctx context.Context, count int, timeout int) error

Scale implements Service.Scale but does nothing.

func (*EmptyService) Start Uses

func (e *EmptyService) Start(ctx context.Context) error

Start implements Service.Start but does nothing.

func (*EmptyService) Stop Uses

func (e *EmptyService) Stop(ctx context.Context, timeout int) error

Stop implements Service.Stop() but does nothing.

func (*EmptyService) Unpause Uses

func (e *EmptyService) Unpause(ctx context.Context) error

Unpause implements Service.Pause but does nothing.

func (*EmptyService) Up Uses

func (e *EmptyService) Up(ctx context.Context, options options.Up) error

Up implements Service.Up but does nothing.

type ExportedConfig Uses

type ExportedConfig struct {
    Version  string                           `yaml:"version,omitempty"`
    Services map[string]*config.ServiceConfig `yaml:"services"`
    Volumes  map[string]*config.VolumeConfig  `yaml:"volumes"`
    Networks map[string]*config.NetworkConfig `yaml:"networks"`
}

ExportedConfig holds config attribute that will be exported

type Filter Uses

type Filter struct {
    State State
}

Filter holds filter element to filter containers

type Info Uses

type Info map[string]string

Info holds a list of InfoPart.

type InfoSet Uses

type InfoSet []Info

InfoSet holds a list of Info.

func (InfoSet) String Uses

func (infos InfoSet) String(columns []string, titleFlag bool) string

type Networks Uses

type Networks interface {
    Initialize(ctx context.Context) error
    Remove(ctx context.Context) error
}

Networks defines the methods a libcompose network aggregate should define.

type NetworksFactory Uses

type NetworksFactory interface {
    Create(projectName string, networkConfigs map[string]*config.NetworkConfig, serviceConfigs *config.ServiceConfigs, networkEnabled bool) (Networks, error)
}

NetworksFactory is an interface factory to create Networks object for the specified configurations (service, networks, …)

type Project Uses

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 Uses

func NewProject(context *Context, runtime RuntimeProject, parseOptions *config.ParseOptions) *Project

NewProject creates a new project with the specified context.

func (*Project) AddConfig Uses

func (p *Project) AddConfig(name string, config *config.ServiceConfig) error

AddConfig adds the specified service config for the specified name.

func (*Project) AddListener Uses

func (p *Project) AddListener(c chan<- events.Event)

AddListener adds the specified listener to the project. This implements implicitly events.Emitter.

func (*Project) AddNetworkConfig Uses

func (p *Project) AddNetworkConfig(name string, config *config.NetworkConfig) error

AddNetworkConfig adds the specified network config for the specified name.

func (*Project) AddVolumeConfig Uses

func (p *Project) AddVolumeConfig(name string, config *config.VolumeConfig) error

AddVolumeConfig adds the specified volume config for the specified name.

func (*Project) Build Uses

func (p *Project) Build(ctx context.Context, buildOptions options.Build, services ...string) error

Build builds the specified services (like docker build).

func (*Project) Config Uses

func (p *Project) Config() (string, error)

Config validates and print the compose file.

func (*Project) Containers Uses

func (p *Project) Containers(ctx context.Context, filter Filter, services ...string) ([]string, error)

Containers lists the containers for the specified services. Can be filter using the Filter struct.

func (*Project) Create Uses

func (p *Project) Create(ctx context.Context, options options.Create, services ...string) error

Create creates the specified services (like docker create).

func (*Project) CreateService Uses

func (p *Project) CreateService(name string) (Service, error)

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) Delete Uses

func (p *Project) Delete(ctx context.Context, options options.Delete, services ...string) error

Delete removes the specified services (like docker rm).

func (*Project) Down Uses

func (p *Project) Down(ctx context.Context, opts options.Down, services ...string) error

Down stops the specified services and clean related containers (like docker stop + docker rm).

func (*Project) Events Uses

func (p *Project) Events(ctx context.Context, services ...string) (chan events.ContainerEvent, error)

Events listen for real time events from containers (of the project).

func (*Project) GetServiceConfig Uses

func (p *Project) GetServiceConfig(name string) (*config.ServiceConfig, bool)

GetServiceConfig looks up a service config for a given service name, returning the ServiceConfig object and a bool flag indicating whether it was found

func (*Project) Kill Uses

func (p *Project) Kill(ctx context.Context, signal string, services ...string) error

Kill kills the specified services (like docker kill).

func (*Project) Load Uses

func (p *Project) Load(bytes []byte) error

Load loads the specified byte array (the composefile content) and adds the service configuration to the project. FIXME is it needed ?

func (*Project) Log Uses

func (p *Project) Log(ctx context.Context, follow bool, services ...string) error

Log aggregates and prints out the logs for the specified services.

func (*Project) Notify Uses

func (p *Project) Notify(eventType events.EventType, serviceName string, data map[string]string)

Notify notifies all project listener with the specified eventType, service name and datas. This implements implicitly events.Notifier interface.

func (*Project) Parse Uses

func (p *Project) Parse() error

Parse populates project information based on its context. It sets up the name, the composefile and the composebytes (the composefile content).

func (*Project) Pause Uses

func (p *Project) Pause(ctx context.Context, services ...string) error

Pause pauses the specified services containers (like docker pause).

func (*Project) Port Uses

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.

func (*Project) Ps Uses

func (p *Project) Ps(ctx context.Context, services ...string) (InfoSet, error)

Ps list containers for the specified services.

func (*Project) Pull Uses

func (p *Project) Pull(ctx context.Context, services ...string) error

Pull pulls the specified services (like docker pull).

func (*Project) Restart Uses

func (p *Project) Restart(ctx context.Context, timeout int, services ...string) error

Restart restarts the specified services (like docker restart).

func (*Project) Run Uses

func (p *Project) Run(ctx context.Context, serviceName string, commandParts []string, opts options.Run) (int, error)

Run executes a one off command (like `docker run image command`).

func (*Project) Scale Uses

func (p *Project) Scale(ctx context.Context, timeout int, servicesScale map[string]int) error

Scale scales the specified services.

func (*Project) Start Uses

func (p *Project) Start(ctx context.Context, services ...string) error

Start starts the specified services (like docker start).

func (*Project) Stop Uses

func (p *Project) Stop(ctx context.Context, timeout int, services ...string) error

Stop stops the specified services (like docker stop).

func (*Project) Unpause Uses

func (p *Project) Unpause(ctx context.Context, services ...string) error

Unpause pauses the specified services containers (like docker pause).

func (*Project) Up Uses

func (p *Project) Up(ctx context.Context, options options.Up, services ...string) error

Up creates and starts the specified services (kinda like docker run).

type RuntimeProject Uses

type RuntimeProject interface {
    RemoveOrphans(ctx context.Context, projectName string, serviceConfigs *config.ServiceConfigs) error
}

RuntimeProject defines runtime-specific methods for a libcompose implementation.

type Service Uses

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
    Events(ctx context.Context, messages chan events.ContainerEvent) error
    Info(ctx context.Context) (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, options options.Run) (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 Uses

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 Uses

type ServiceRelationship struct {
    Target, Alias string
    Type          ServiceRelationshipType
    Optional      bool
}

ServiceRelationship holds the relationship information between two services.

func NewServiceRelationship Uses

func NewServiceRelationship(nameAlias string, relType ServiceRelationshipType) ServiceRelationship

NewServiceRelationship creates a new Relationship based on the specified alias and relationship type.

type ServiceRelationshipType Uses

type ServiceRelationshipType string

ServiceRelationshipType defines the type of service relationship.

type ServiceState Uses

type ServiceState string

ServiceState holds the state of a service.

type State Uses

type State string

State defines the supported state you can filter on

type Volumes Uses

type Volumes interface {
    Initialize(ctx context.Context) error
    Remove(ctx context.Context) error
}

Volumes defines the methods a libcompose volume aggregate should define.

type VolumesFactory Uses

type VolumesFactory interface {
    Create(projectName string, volumeConfigs map[string]*config.VolumeConfig, serviceConfigs *config.ServiceConfigs, volumeEnabled bool) (Volumes, error)
}

VolumesFactory is an interface factory to create Volumes object for the specified configurations (service, volumes, …)

Directories

PathSynopsis
eventsPackage events holds event structures, methods and functions.
options

Package project imports 22 packages (graph) and is imported by 189 packages. Updated 2017-10-26. Refresh now. Tools for package owners.