compose

package
v0.0.0-...-c57eb44 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: BSD-3-Clause Imports: 24 Imported by: 0

README

Compose

The package compose handles docker-compose tool, with validation, patching and running.

ComposeValidator groups a collection of VolumeValidator and ServiceValidator and validate a docker-compose.yml file.

Recomposatorgroups a collection of VolumePatcher and ServicePatcherand create a patched docker-compose.yml file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureBin

func EnsureBin() error

EnsureBin will ensure that docker-compose is found in $PATH

func SnakeToCamel

func SnakeToCamel(txt string) string

func SubnetFromDocker

func SubnetFromDocker(docker *client.Client) ([]*net.IPNet, error)

func ValidateNoDotDot

func ValidateNoDotDot(src, dest string, ro bool) error

func ValidateVolumeInplace

func ValidateVolumeInplace(src, dest string, ro bool) error

Types

type Compose

type Compose struct {
	Networks map[string]interface{} `json:"networks,omitempty"`
	Volumes  map[string]interface{} `json:"volumes,omitempty"`
	Version  string                 `json:"version"` // Compose version
	Services map[string]interface{} `json:"services"`
	X        map[string]interface{} `json:"X,omitempty"` // The x-stuff on top level, just for aliasing
}

Compose is a docker-compose project FIXME there is more first level keys, like volume or networks

func NewCompose

func NewCompose() *Compose

NewCompose inits a compose struct

func (*Compose) InjectCacheVolume

func (c *Compose) InjectCacheVolume()

InjectCacheVolume adds cache directory as volume to each service in a compose file

func (Compose) MarshalYAML

func (c Compose) MarshalYAML() (interface{}, error)

MarshalYAML is used to marshal a Compose back to its yaml form

func (Compose) NewServiceGraph

func (c Compose) NewServiceGraph() ServiceGraph

NewServiceGraph generates a graph of deps from a compose description

func (*Compose) RegisteredName

func (c *Compose) RegisteredName() string

func (*Compose) UnmarshalYAML

func (c *Compose) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML is used to unmarshal a docker-compose (yaml) file

func (Compose) Up

func (c Compose) Up(workingDirectory string, environments map[string]string, runID int) (_run.Run, error)

Up compose action

func (Compose) Validate

func (c Compose) Validate() error

Validate compose content

func (*Compose) WalkServices

func (c *Compose) WalkServices(fn func(name string, value map[string]interface{}) error) error

type ComposeValidator

type ComposeValidator struct {
	// contains filtered or unexported fields
}
var (
	StandardValidtator *ComposeValidator
	StandardConfig     map[string]interface{}
)

func NewComposeValidtor

func NewComposeValidtor(cfg map[string]interface{}) (*ComposeValidator, error)

func (*ComposeValidator) UseServiceValidator

func (cv *ComposeValidator) UseServiceValidator(s ServiceValidator)

func (*ComposeValidator) UseVolumeValidator

func (cv *ComposeValidator) UseVolumeValidator(v VolumeValidator)

func (*ComposeValidator) Validate

func (cv *ComposeValidator) Validate(c *Compose) []error

type DockerRun

type DockerRun struct {
	Path     string    `json:"path"`
	RID      string    `json:"runner_id"` // RID is internal ID used by the docker runner
	ID       int       `json:"id"`        // ID is the density run ID for this task
	Start    time.Time `json:"start"`
	Finish   time.Time `json:"down"`
	ExitCode int       `json:"exit_code"`
	Running  bool      `json:"running"`
}

DockerRun implements task.Run for Docker

func (*DockerRun) Data

func (d *DockerRun) Data() _run.Data

Data returns all the data that should be exposed to the outside world

func (*DockerRun) Down

func (d *DockerRun) Down() error

func (*DockerRun) RegisteredName

func (d *DockerRun) RegisteredName() string

func (*DockerRun) RunnerID

func (d *DockerRun) RunnerID() (string, error)

RunnerID will return the Docker container ID of the main container for this run

func (*DockerRun) Status

func (d *DockerRun) Status() (_run.Status, int, error)

func (*DockerRun) Wait

func (d *DockerRun) Wait(ctx context.Context) (_status.Status, error)

type Networks

type Networks struct {
	// contains filtered or unexported fields
}

func NewNetworks

func NewNetworks(docker *client.Client) *Networks

func (*Networks) New

func (n *Networks) New(project string) (string, error)

func (*Networks) Remove

func (n *Networks) Remove(network string) error

type Recomposator

type Recomposator struct {
	// contains filtered or unexported fields
}

func NewRecomposator

func NewRecomposator(docker *client.Client, cfg map[string]interface{}) (*Recomposator, error)

func StandardRecomposator

func StandardRecomposator(docker *client.Client) (*Recomposator, error)

func (*Recomposator) Recompose

func (r *Recomposator) Recompose(name string, c *Compose) (*Compose, error)

Recompose take a naive and validated Compose and return a Compose as it will be run

func (*Recomposator) UseServicePatcher

func (r *Recomposator) UseServicePatcher(p ServicePatcher)

func (*Recomposator) UseVolumePatcher

func (r *Recomposator) UseVolumePatcher(p VolumePatcher)

type ServiceDepth

type ServiceDepth map[string]int

ServiceDepth represents the level of deps for a services

func (ServiceDepth) Len

func (sd ServiceDepth) Len() int

Len is used by the sort interface

type ServiceGraph

type ServiceGraph map[string]([]string)

ServiceGraph represents a map of services to dependencies

func (ServiceGraph) ByServiceDepth

func (s ServiceGraph) ByServiceDepth() ServiceDepth

ByServiceDepth computes deps depth by service

type ServicePatcher

type ServicePatcher func(service map[string]interface{}) error

type ServiceValidator

type ServiceValidator func(service map[string]interface{}) error

type VolumePatcher

type VolumePatcher func(src string) (string, error)

func PatchVolumeInVolumes

func PatchVolumeInVolumes(target string) (VolumePatcher, error)

type VolumeValidator

type VolumeValidator func(source, destination string, readOnly bool) error

func ValidateNotAsDeep

func ValidateNotAsDeep(deep int) VolumeValidator

Jump to

Keyboard shortcuts

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