project

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2016 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoEvent = EventType(iota)

	EventContainerCreated = EventType(iota)
	EventContainerStarted = EventType(iota)

	EventServiceAdd          = EventType(iota)
	EventServiceUpStart      = EventType(iota)
	EventServiceUpIgnored    = EventType(iota)
	EventServiceUp           = EventType(iota)
	EventServiceCreateStart  = EventType(iota)
	EventServiceCreate       = EventType(iota)
	EventServiceDeleteStart  = EventType(iota)
	EventServiceDelete       = EventType(iota)
	EventServiceDownStart    = EventType(iota)
	EventServiceDown         = EventType(iota)
	EventServiceRestartStart = EventType(iota)
	EventServiceRestart      = EventType(iota)
	EventServicePullStart    = EventType(iota)
	EventServicePull         = EventType(iota)
	EventServiceKillStart    = EventType(iota)
	EventServiceKill         = EventType(iota)
	EventServiceStartStart   = EventType(iota)
	EventServiceStart        = EventType(iota)
	EventServiceBuildStart   = EventType(iota)
	EventServiceBuild        = EventType(iota)
	EventServicePauseStart   = EventType(iota)
	EventServicePause        = EventType(iota)
	EventServiceUnpauseStart = EventType(iota)
	EventServiceUnpause      = EventType(iota)
	EventServiceStopStart    = EventType(iota)
	EventServiceStop         = EventType(iota)
	EventServiceRunStart     = EventType(iota)
	EventServiceRun          = EventType(iota)

	EventProjectDownStart     = EventType(iota)
	EventProjectDownDone      = EventType(iota)
	EventProjectCreateStart   = EventType(iota)
	EventProjectCreateDone    = EventType(iota)
	EventProjectUpStart       = EventType(iota)
	EventProjectUpDone        = EventType(iota)
	EventProjectDeleteStart   = EventType(iota)
	EventProjectDeleteDone    = EventType(iota)
	EventProjectRestartStart  = EventType(iota)
	EventProjectRestartDone   = EventType(iota)
	EventProjectReload        = EventType(iota)
	EventProjectReloadTrigger = EventType(iota)
	EventProjectKillStart     = EventType(iota)
	EventProjectKillDone      = EventType(iota)
	EventProjectStartStart    = EventType(iota)
	EventProjectStartDone     = EventType(iota)
	EventProjectBuildStart    = EventType(iota)
	EventProjectBuildDone     = EventType(iota)
	EventProjectPauseStart    = EventType(iota)
	EventProjectPauseDone     = EventType(iota)
	EventProjectUnpauseStart  = EventType(iota)
	EventProjectUnpauseDone   = EventType(iota)
	EventProjectStopStart     = EventType(iota)
	EventProjectStopDone      = EventType(iota)
)

Definitions of libcompose events

View Source
const RelTypeIpcNamespace = ServiceRelationshipType("ipc")

RelTypeIpcNamespace means the service share the same ipc namespace.

View Source
const RelTypeLink = ServiceRelationshipType("")

RelTypeLink means the services are linked (docker links).

View Source
const RelTypeNetNamespace = ServiceRelationshipType("netns")

RelTypeNetNamespace means the services share the same network namespace.

View Source
const RelTypeVolumesFrom = ServiceRelationshipType("volumesFrom")

RelTypeVolumesFrom means the services share some volumes.

Variables

View Source
var (
	StateExecuted = ServiceState("executed")
	StateUnknown  = ServiceState("unknown")
)

State definitions

View Source
var (
	ErrRestart     = errors.New("Restart execution")
	ErrUnsupported = errors.New("UnsupportedOperation")
)

Error definitions

Functions

func GetContainerFromIpcLikeConfig

func GetContainerFromIpcLikeConfig(p *Project, conf string) string

GetContainerFromIpcLikeConfig returns name of the service that shares the IPC namespace with the specified service.

func NameAlias

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

func NewDefaultListener(p *Project) chan<- Event

NewDefaultListener create a default listener for the specified project.

Types

type Container

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

Container defines what a libcompose container provides.

type Context

type Context struct {
	Timeout       uint
	Log           bool
	Volume        bool
	ForceRecreate bool
	NoRecreate    bool
	NoCache       bool
	NoBuild       bool
	Signal        string
	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) Build

func (e *EmptyService) Build() error

Build implements Service.Build but does nothing.

func (*EmptyService) Containers

func (e *EmptyService) Containers() ([]Container, error)

Containers implements Service.Containers but does nothing.

func (*EmptyService) Create

func (e *EmptyService) Create() error

Create implements Service.Create but does nothing.

func (*EmptyService) Delete

func (e *EmptyService) Delete() error

Delete implements Service.Delete but does nothing.

func (*EmptyService) Down

func (e *EmptyService) Down() error

Down implements Service.Down but does nothing.

func (*EmptyService) Info

func (e *EmptyService) Info(qFlag bool) (InfoSet, error)

Info implements Service.Info but does nothing.

func (*EmptyService) Kill

func (e *EmptyService) Kill() error

Kill implements Service.Kill but does nothing.

func (*EmptyService) Log

func (e *EmptyService) Log() error

Log implements Service.Log but does nothing.

func (*EmptyService) Pause

func (e *EmptyService) Pause() error

Pause implements Service.Pause but does nothing.

func (*EmptyService) Pull

func (e *EmptyService) Pull() error

Pull implements Service.Pull but does nothing.

func (*EmptyService) Restart

func (e *EmptyService) Restart() error

Restart implements Service.Restart but does nothing.

func (*EmptyService) Scale

func (e *EmptyService) Scale(count int) error

Scale implements Service.Scale but does nothing.

func (*EmptyService) Start

func (e *EmptyService) Start() error

Start implements Service.Start but does nothing.

func (*EmptyService) Stop added in v0.2.0

func (e *EmptyService) Stop() error

Stop implements Service.Stop() but does nothing.

func (*EmptyService) Unpause

func (e *EmptyService) Unpause() error

Unpause implements Service.Pause but does nothing.

func (*EmptyService) Up

func (e *EmptyService) Up() error

Up implements Service.Up but does nothing.

type Event

type Event struct {
	EventType   EventType
	ServiceName string
	Data        map[string]string
}

Event holds project-wide event informations.

type EventType

type EventType int

EventType defines a type of libcompose event.

func (EventType) String

func (e EventType) String() string

type Info

type Info []InfoPart

Info holds a list of InfoPart.

type InfoPart

type InfoPart struct {
	Key, Value string
}

InfoPart holds key/value strings.

type InfoSet

type InfoSet []Info

InfoSet holds a list of Info.

func (InfoSet) String

func (infos InfoSet) String(titleFlag bool) string

type Project

type Project struct {
	Name           string
	Configs        *config.Configs
	Files          []string
	ReloadCallback func() error
	// contains filtered or unexported fields
}

Project holds libcompose project information.

func NewProject

func NewProject(context *Context) *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

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

AddListener adds the specified listener to the project.

func (*Project) Build

func (p *Project) Build(services ...string) error

Build builds the specified services (like docker build).

func (*Project) Create

func (p *Project) Create(services ...string) error

Create creates the specified services (like docker create).

func (*Project) CreateService

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

func (p *Project) Delete(services ...string) error

Delete removes the specified services (like docker rm).

func (*Project) Down

func (p *Project) Down(services ...string) error

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

func (*Project) Kill

func (p *Project) Kill(services ...string) error

Kill kills the specified services (like docker kill).

func (*Project) ListStoppedContainers

func (p *Project) ListStoppedContainers(services ...string) ([]string, error)

ListStoppedContainers lists the stopped containers for the specified services.

func (*Project) Load

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

func (p *Project) Log(services ...string) error

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

func (*Project) Notify

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

Notify notifies all project listener with the specified eventType, service name and datas.

func (*Project) Parse

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

func (p *Project) Pause(services ...string) error

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

func (*Project) Pull

func (p *Project) Pull(services ...string) error

Pull pulls the specified services (like docker pull).

func (*Project) Restart

func (p *Project) Restart(services ...string) error

Restart restarts the specified services (like docker restart).

func (*Project) Run added in v0.2.0

func (p *Project) Run(serviceName string, commandParts []string) (int, error)

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

func (*Project) Start

func (p *Project) Start(services ...string) error

Start starts the specified services (like docker start).

func (*Project) Stop added in v0.2.0

func (p *Project) Stop(services ...string) error

Stop stops the specified services (like docker stop).

func (*Project) Unpause

func (p *Project) Unpause(services ...string) error

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

func (*Project) Up

func (p *Project) Up(services ...string) error

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

type Service

type Service interface {
	Info(qFlag bool) (InfoSet, error)
	Name() string
	Build() error
	Create() error
	Up() error
	Start() error
	Stop() error
	Down() error
	Delete() error
	Restart() error
	Log() error
	Pull() error
	Kill() error
	Config() *config.ServiceConfig
	DependentServices() []ServiceRelationship
	Containers() ([]Container, error)
	Scale(count int) error
	Pause() error
	Unpause() error
	Run(commandParts []string) (int, error)
}

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.

type ServiceState

type ServiceState string

ServiceState holds the state of a service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL