dockercompose

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatError

func FormatError(cmd *exec.Cmd, stdout []byte, err error) error

Types

type Action

type Action int
const (

	// CONTAINER actions
	ActionUnknown Action = iota
	ActionAttach
	ActionCommit
	ActionCopy
	ActionCreate
	ActionDestroy
	ActionDie
	ActionExecCreate
	ActionExecDetach
	ActionExecDie
	ActionExecStart
	ActionExport
	ActionHealthStatus
	ActionKill
	ActionOom
	ActionPause
	ActionRename
	ActionResize
	ActionRestart
	ActionStart
	ActionStop
	ActionTop
	ActionUnpause
	ActionUpdate
)

func (Action) MarshalJSON added in v0.4.3

func (a Action) MarshalJSON() ([]byte, error)

func (Action) String added in v0.4.3

func (a Action) String() string

func (*Action) UnmarshalJSON

func (a *Action) UnmarshalJSON(b []byte) error

type Attributes

type Attributes struct {
	Name  string `json:"name"`
	Image string `json:"image"`
}

type BuildConfig

type BuildConfig struct {
	Context    string `yaml:"context"`
	Dockerfile string `yaml:"dockerfile"`
}

type Config

type Config struct {
	Services map[string]ServiceConfig
}

Go representations of docker-compose.yml (Add fields as we need to support more things)

func ReadConfigAndServiceNames added in v0.10.8

func ReadConfigAndServiceNames(ctx context.Context, dcc DockerComposeClient,
	configPaths []string) (conf Config, svcNames []string, err error)

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

We use a custom Unmarshal method here so that we can store the RawYAML in addition to unmarshaling the fields we care about into structs.

type DockerComposeClient

type DockerComposeClient interface {
	Up(ctx context.Context, configPaths []string, serviceName model.TargetName, shouldBuild bool, stdout, stderr io.Writer) error
	Down(ctx context.Context, configPaths []string, stdout, stderr io.Writer) error
	StreamLogs(ctx context.Context, configPaths []string, serviceName model.TargetName) (io.ReadCloser, error)
	StreamEvents(ctx context.Context, configPaths []string) (<-chan string, error)
	Config(ctx context.Context, configPaths []string) (string, error)
	Services(ctx context.Context, configPaths []string) (string, error)
	ContainerID(ctx context.Context, configPaths []string, serviceName model.TargetName) (container.ID, error)
}

func NewDockerComposeClient

func NewDockerComposeClient(env docker.LocalEnv) DockerComposeClient

TODO(dmiller): we might want to make this take a path to the docker-compose config so we don't have to keep passing it in.

type Event

type Event struct {
	Time       string     `json:"time"` // todo: time
	Type       Type       `json:"type"`
	Action     Action     `json:"action"`
	ID         string     `json:"id"` // todo: type?
	Service    string     `json:"service"`
	Attributes Attributes `json:"attributes"`
}

func EventFromJsonStr

func EventFromJsonStr(j string) (Event, error)

func (Event) IsStartupEvent added in v0.4.2

func (evt Event) IsStartupEvent() bool

type FakeDCClient

type FakeDCClient struct {
	RunLogOutput      map[model.TargetName]<-chan string
	ContainerIdOutput container.ID

	ConfigOutput   string
	ServicesOutput string

	UpCalls   []UpCall
	DownError error
	// contains filtered or unexported fields
}

func NewFakeDockerComposeClient

func NewFakeDockerComposeClient(t *testing.T, ctx context.Context) *FakeDCClient

func (*FakeDCClient) Config

func (c *FakeDCClient) Config(ctx context.Context, configPaths []string) (string, error)

func (*FakeDCClient) ContainerID added in v0.5.1

func (c *FakeDCClient) ContainerID(ctx context.Context, configPaths []string, serviceName model.TargetName) (container.ID, error)

func (*FakeDCClient) Down

func (c *FakeDCClient) Down(ctx context.Context, configPaths []string, stdout, stderr io.Writer) error

func (*FakeDCClient) SendEvent

func (c *FakeDCClient) SendEvent(evt Event) error

func (*FakeDCClient) Services

func (c *FakeDCClient) Services(ctx context.Context, configPaths []string) (string, error)

func (*FakeDCClient) StreamEvents

func (c *FakeDCClient) StreamEvents(ctx context.Context, configPaths []string) (<-chan string, error)

func (*FakeDCClient) StreamLogs

func (c *FakeDCClient) StreamLogs(ctx context.Context, configPaths []string, serviceName model.TargetName) (io.ReadCloser, error)

func (*FakeDCClient) Up

func (c *FakeDCClient) Up(ctx context.Context, configPaths []string, serviceName model.TargetName,
	shouldBuild bool, stdout, stderr io.Writer) error

type Port added in v0.10.8

type Port struct {
	Published int `yaml:"published"`
}

type Ports added in v0.10.8

type Ports []Port

func (*Ports) UnmarshalYAML added in v0.10.8

func (p *Ports) UnmarshalYAML(unmarshal func(interface{}) error) error

type ServiceConfig

type ServiceConfig struct {
	RawYAML []byte      // We store this to diff against when docker-compose.yml is edited to see if the manifest has changed
	Build   BuildConfig `yaml:"build"`
	Image   string      `yaml:"image"`
	Volumes Volumes     `yaml:"volumes"`
	Ports   Ports       `yaml:"ports"`
}

type State

type State struct {
	ContainerState types.ContainerState
	ContainerID    container.ID

	// TODO(nick): It might make since to get rid of StartTime
	// and parse it out of the ContainerState.StartedAt string,
	// though we would have to decide how to treat containers
	// started before Tilt start.
	StartTime time.Time

	LastReadyTime time.Time

	SpanID model.LogSpanID
}

func (State) HasEverBeenReadyOrSucceeded added in v0.14.0

func (s State) HasEverBeenReadyOrSucceeded() bool

func (State) RuntimeState added in v0.10.5

func (State) RuntimeState()

func (State) RuntimeStatus added in v0.14.0

func (s State) RuntimeStatus() model.RuntimeStatus

func (State) RuntimeStatusError added in v0.14.0

func (s State) RuntimeStatusError() error

func (State) WithContainerID added in v0.5.0

func (s State) WithContainerID(cID container.ID) State

func (State) WithContainerState added in v0.14.0

func (s State) WithContainerState(state types.ContainerState) State

func (State) WithLastReadyTime added in v0.10.15

func (s State) WithLastReadyTime(time time.Time) State

func (State) WithSpanID added in v0.10.25

func (s State) WithSpanID(spanID model.LogSpanID) State

func (State) WithStartTime added in v0.4.2

func (s State) WithStartTime(time time.Time) State

type Type

type Type int

https://docs.docker.com/engine/reference/commandline/events/

const (
	// Add 'types' here (and to `stringToType` below) as we support them
	TypeUnknown Type = iota
	TypeContainer
)

func (Type) MarshalJSON added in v0.4.3

func (t Type) MarshalJSON() ([]byte, error)

func (Type) String added in v0.4.3

func (t Type) String() string

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(b []byte) error

type UpCall added in v0.6.0

type UpCall struct {
	PathToConfig []string
	ServiceName  model.TargetName
	ShouldBuild  bool
}

Represents a single call to Up

type Volume added in v0.10.8

type Volume struct {
	Source string
}

type Volumes added in v0.10.8

type Volumes []Volume

func (*Volumes) UnmarshalYAML added in v0.10.8

func (v *Volumes) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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