Documentation
¶
Index ¶
- Constants
- type ContainerEvent
- type ContainerEventListener
- type ContainerSummary
- type ConvertOptions
- type CreateOptions
- type DownOptions
- type KillOptions
- type ListOptions
- type LogConsumer
- type LogOptions
- type PortPublisher
- type PsOptions
- type RemoveOptions
- type RunOptions
- type Service
- type ServiceStatus
- type Stack
- type StartOptions
- type StopOptions
- type UpOptions
Constants ¶
const ( // STARTING indicates that stack is being deployed STARTING string = "Starting" // RUNNING indicates that stack is deployed and services are running RUNNING string = "Running" // UPDATING indicates that some stack resources are being recreated UPDATING string = "Updating" // REMOVING indicates that stack is being deleted REMOVING string = "Removing" // UNKNOWN indicates unknown stack state UNKNOWN string = "Unknown" // FAILED indicates that stack deployment failed FAILED string = "Failed" )
const ( // RecreateDiverged to recreate services which configuration diverges from compose model RecreateDiverged = "diverged" // RecreateForce to force service container being recreated RecreateForce = "force" // RecreateNever to never recreate existing service containers RecreateNever = "never" )
const ( // ContainerEventLog is a ContainerEvent of type log. Line is set ContainerEventLog = iota // ContainerEventAttach is a ContainerEvent of type attach. First event sent about a container ContainerEventAttach // ContainerEventExit is a ContainerEvent of type exit. ExitCode is set ContainerEventExit // UserCancel user cancelled compose up, we are stopping containers UserCancel )
const ( // ProjectTag allow to track resource related to a compose project ProjectTag = "com.docker.compose.project" // NetworkTag allow to track resource related to a compose network NetworkTag = "com.docker.compose.network" // ServiceTag allow to track resource related to a compose service ServiceTag = "com.docker.compose.service" // VolumeTag allow to track resource related to a compose volume VolumeTag = "com.docker.compose.volume" // EnvironmentFileLabel is set in containers with the option "--env-file" when set EnvironmentFileLabel = "com.docker.compose.project.environment_file" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContainerEvent ¶ added in v1.0.9
type ContainerEvent struct {
Type int
Source string
Service string
Name string
Line string
ExitCode int
}
ContainerEvent notify an event has been collected on Source container implementing Service
type ContainerEventListener ¶ added in v1.0.9
type ContainerEventListener func(event ContainerEvent)
ContainerEventListener is a callback to process ContainerEvent from services
type ContainerSummary ¶ added in v1.0.5
type ContainerSummary struct {
ID string
Name string
Project string
Service string
State string
Health string
Publishers []PortPublisher
}
ContainerSummary hold high-level description of a container
type ConvertOptions ¶ added in v1.0.6
type ConvertOptions struct {
// Format define the output format used to dump converted application model (json|yaml)
Format string
// Output defines the path to save the application model
Output string
}
ConvertOptions group options of the Convert API
type CreateOptions ¶ added in v1.0.7
type CreateOptions struct {
// Remove legacy containers for services that are not defined in the project
RemoveOrphans bool
// Recreate define the strategy to apply on existing containers
Recreate string
}
CreateOptions group options of the Create API
type DownOptions ¶ added in v1.0.6
type DownOptions struct {
// RemoveOrphans will cleanup containers that are not declared on the compose model but own the same labels
RemoveOrphans bool
// Project is the compose project used to define this app. Might be nil if user ran `down` just with project name
Project *types.Project
// Timeout override container stop timeout
Timeout *time.Duration
// Images remove image used by services. 'all': Remove all images. 'local': Remove only images that don't have a tag
Images string
// Volumes remove volumes, both declared in the `volumes` section and anonymous ones
Volumes bool
}
DownOptions group options of the Down API
type KillOptions ¶ added in v1.0.8
type KillOptions struct {
// Signal to send to containers
Signal string
}
KillOptions group options of the Kill API
type ListOptions ¶ added in v1.0.9
type ListOptions struct {
All bool
}
ListOptions group options of the ls API
type LogConsumer ¶ added in v1.0.4
type LogConsumer interface {
Log(name, service, container, message string)
Status(name, container, msg string)
Register(name string, source string)
}
LogConsumer is a callback to process log messages from services
type LogOptions ¶ added in v1.0.6
LogOptions defines optional parameters for the `Log` API
type PortPublisher ¶
PortPublisher hold status about published port
type PsOptions ¶ added in v1.0.8
type PsOptions struct {
All bool
}
PsOptions group options of the Ps API
type RemoveOptions ¶ added in v1.0.9
type RemoveOptions struct {
// DryRun just list removable resources
DryRun bool
// Volumes remove anonymous volumes
Volumes bool
// Force don't ask to confirm removal
Force bool
}
RemoveOptions group options of the Remove API
type RunOptions ¶ added in v1.0.6
type RunOptions struct {
Name string
Service string
Command []string
Entrypoint []string
Detach bool
AutoRemove bool
Writer io.Writer
Reader io.Reader
Tty bool
WorkingDir string
User string
Environment []string
Labels types.Labels
Privileged bool
// used by exec
Index int
}
RunOptions options to execute compose run
func (*RunOptions) EnvironmentMap ¶ added in v1.0.9
func (opts *RunOptions) EnvironmentMap() types.MappingWithEquals
EnvironmentMap return RunOptions.Environment as a MappingWithEquals
type Service ¶
type Service interface {
// Build executes the equivalent to a `compose build`
Build(ctx context.Context, project *types.Project) error
// Push executes the equivalent ot a `compose push`
Push(ctx context.Context, project *types.Project) error
// Pull executes the equivalent of a `compose pull`
Pull(ctx context.Context, project *types.Project) error
// Create executes the equivalent to a `compose create`
Create(ctx context.Context, project *types.Project, opts CreateOptions) error
// Start executes the equivalent to a `compose start`
Start(ctx context.Context, project *types.Project, options StartOptions) error
// Stop executes the equivalent to a `compose stop`
Stop(ctx context.Context, project *types.Project, options StopOptions) error
// Up executes the equivalent to a `compose up`
Up(ctx context.Context, project *types.Project, options UpOptions) error
// Down executes the equivalent to a `compose down`
Down(ctx context.Context, projectName string, options DownOptions) error
// Logs executes the equivalent to a `compose logs`
Logs(ctx context.Context, projectName string, consumer LogConsumer, options LogOptions) error
// Ps executes the equivalent to a `compose ps`
Ps(ctx context.Context, projectName string, options PsOptions) ([]ContainerSummary, error)
// List executes the equivalent to a `docker stack ls`
List(ctx context.Context, options ListOptions) ([]Stack, error)
// Convert translate compose model into backend's native format
Convert(ctx context.Context, project *types.Project, options ConvertOptions) ([]byte, error)
// Kill executes the equivalent to a `compose kill`
Kill(ctx context.Context, project *types.Project, options KillOptions) error
// RunOneOffContainer creates a service oneoff container and starts its dependencies
RunOneOffContainer(ctx context.Context, project *types.Project, opts RunOptions) (int, error)
// Remove executes the equivalent to a `compose rm`
Remove(ctx context.Context, project *types.Project, options RemoveOptions) ([]string, error)
// Exec executes a command in a running service container
Exec(ctx context.Context, project *types.Project, opts RunOptions) error
// Pause executes the equivalent to a `compose pause`
Pause(ctx context.Context, project *types.Project) error
// UnPause executes the equivalent to a `compose unpause`
UnPause(ctx context.Context, project *types.Project) error
}
Service manages a compose project
type ServiceStatus ¶
type ServiceStatus struct {
ID string
Name string
Replicas int
Desired int
Ports []string
Publishers []PortPublisher
}
ServiceStatus hold status about a service
type StartOptions ¶ added in v1.0.9
type StartOptions struct {
// Attach will attach to service containers and send container logs and events
Attach ContainerEventListener
}
StartOptions group options of the Start API
type StopOptions ¶ added in v1.0.9
StopOptions group options of the Stop API