package compose
import "github.com/docker/compose/v2/pkg/compose"
Index ¶
- Constants
- Variables
- func InDependencyOrder(ctx context.Context, project *types.Project, fn func(context.Context, string) error, options ...func(*graphTraversal)) error
- func InReverseDependencyOrder(ctx context.Context, project *types.Project, fn func(context.Context, string) error, options ...func(*graphTraversal)) error
- func NewComposeService(dockerCli command.Cli) api.Service
- func ServiceHash(o types.ServiceConfig) (string, error)
- func ToMobyEnv(environment compose.MappingWithEquals) []string
- func ToMobyHealthCheck(check *compose.HealthCheckConfig) *container.HealthConfig
- func ToSeconds(d *compose.Duration) *int
- func WithRootNodesAndDown(nodes []string) func(*graphTraversal)
- func WrapCategorisedComposeError(err error, failure FailureCategory) error
- func WrapComposeError(err error) error
- type ContainerStdin
- type ContainerStdout
- type Containers
- type DevelopmentConfig
- type Error
- func (e Error) Error() string
- func (e Error) GetMetricsFailureCategory() FailureCategory
- func (e Error) Unwrap() error
- type FailureCategory
- type Graph
- func NewGraph(project *types.Project, initialStatus ServiceStatus) (*Graph, error)
- func (g *Graph) AddEdge(source string, destination string) error
- func (g *Graph) AddVertex(key string, service string, initialStatus ServiceStatus)
- func (g *Graph) FilterChildren(key string, status ServiceStatus) []*Vertex
- func (g *Graph) FilterParents(key string, status ServiceStatus) []*Vertex
- func (g *Graph) HasCycles() (bool, error)
- func (g *Graph) Leaves() []*Vertex
- func (g *Graph) Roots() []*Vertex
- func (g *Graph) UpdateStatus(key string, status ServiceStatus)
- type ImagePruneMode
- type ImagePruneOptions
- type ImagePruner
- func NewImagePruner(imageClient client.ImageAPIClient, project *types.Project) *ImagePruner
- func (p *ImagePruner) ImagesToPrune(ctx context.Context, opts ImagePruneOptions) ([]string, error)
- type ServiceStatus
- type Trigger
- type Vertex
Constants ¶
const ( // ContainerCreated created status ContainerCreated = "created" // ContainerRestarting restarting status ContainerRestarting = "restarting" // ContainerRunning running status ContainerRunning = "running" // ContainerRemoving removing status ContainerRemoving = "removing" // ContainerPaused paused status ContainerPaused = "paused" // ContainerExited exited status ContainerExited = "exited" // ContainerDead dead status ContainerDead = "dead" )
const ( // APISource is sent for API metrics APISource = "api" // SuccessStatus command success SuccessStatus = "success" // FailureStatus command failure FailureStatus = "failure" // ComposeParseFailureStatus failure while parsing compose file ComposeParseFailureStatus = "failure-compose-parse" // FileNotFoundFailureStatus failure getting compose file FileNotFoundFailureStatus = "failure-file-not-found" // CommandSyntaxFailureStatus failure reading command CommandSyntaxFailureStatus = "failure-cmd-syntax" // BuildFailureStatus failure building imge BuildFailureStatus = "failure-build" // PullFailureStatus failure pulling imge PullFailureStatus = "failure-pull" // CanceledStatus command canceled CanceledStatus = "canceled" )
const ( PreparingPhase = "Preparing" WaitingPhase = "Waiting" PullingFsPhase = "Pulling fs layer" DownloadingPhase = "Downloading" DownloadCompletePhase = "Download complete" ExtractingPhase = "Extracting" VerifyingChecksumPhase = "Verifying Checksum" AlreadyExistsPhase = "Already exists" PullCompletePhase = "Pull complete" )
const ( WatchActionSync = "sync" WatchActionRebuild = "rebuild" )
const ServiceConditionRunningOrHealthy = "running_or_healthy"
ServiceConditionRunningOrHealthy is a service condition on status running or healthy
Variables ¶
var ( // FileNotFoundFailure failure for compose file not found FileNotFoundFailure = FailureCategory{MetricsStatus: FileNotFoundFailureStatus, ExitCode: 14} // ComposeParseFailure failure for composefile parse error ComposeParseFailure = FailureCategory{MetricsStatus: ComposeParseFailureStatus, ExitCode: 15} // CommandSyntaxFailure failure for command line syntax CommandSyntaxFailure = FailureCategory{MetricsStatus: CommandSyntaxFailureStatus, ExitCode: 16} // BuildFailure failure while building images. BuildFailure = FailureCategory{MetricsStatus: BuildFailureStatus, ExitCode: 17} // PullFailure failure while pulling image PullFailure = FailureCategory{MetricsStatus: PullFailureStatus, ExitCode: 18} )
Functions ¶
func InDependencyOrder ¶
func InDependencyOrder(ctx context.Context, project *types.Project, fn func(context.Context, string) error, options ...func(*graphTraversal)) error
InDependencyOrder applies the function to the services of the project taking in account the dependency order
func InReverseDependencyOrder ¶
func InReverseDependencyOrder(ctx context.Context, project *types.Project, fn func(context.Context, string) error, options ...func(*graphTraversal)) error
InReverseDependencyOrder applies the function to the services of the project in reverse order of dependencies
func NewComposeService ¶
NewComposeService create a local implementation of the compose.Service API
func ServiceHash ¶
func ServiceHash(o types.ServiceConfig) (string, error)
ServiceHash computes the configuration hash for a service.
func ToMobyEnv ¶
func ToMobyEnv(environment compose.MappingWithEquals) []string
ToMobyEnv convert into []string
func ToMobyHealthCheck ¶
func ToMobyHealthCheck(check *compose.HealthCheckConfig) *container.HealthConfig
ToMobyHealthCheck convert into container.HealthConfig
func ToSeconds ¶
ToSeconds convert into seconds
func WithRootNodesAndDown ¶
func WithRootNodesAndDown(nodes []string) func(*graphTraversal)
func WrapCategorisedComposeError ¶
func WrapCategorisedComposeError(err error, failure FailureCategory) error
WrapCategorisedComposeError wraps the error if not nil, otherwise returns nil
func WrapComposeError ¶
WrapComposeError wraps the error if not nil, otherwise returns nil
Types ¶
type ContainerStdin ¶
type ContainerStdin struct { moby.HijackedResponse }
ContainerStdin implement WriteCloser for moby.HijackedResponse
func (ContainerStdin) Close ¶
func (c ContainerStdin) Close() error
Close implement io.WriteCloser
func (ContainerStdin) Write ¶
func (c ContainerStdin) Write(p []byte) (n int, err error)
Write implement io.WriteCloser
type ContainerStdout ¶
type ContainerStdout struct { moby.HijackedResponse }
ContainerStdout implement ReadCloser for moby.HijackedResponse
func (ContainerStdout) Close ¶
func (l ContainerStdout) Close() error
Close implement io.ReadCloser
func (ContainerStdout) Read ¶
func (l ContainerStdout) Read(p []byte) (n int, err error)
Read implement io.ReadCloser
type Containers ¶
Containers is a set of moby Container
type DevelopmentConfig ¶
type DevelopmentConfig struct { Watch []Trigger `json:"watch,omitempty"` }
type Error ¶
type Error struct { Err error Category *FailureCategory }
Error error to categorize failures and extract metrics info
func (Error) Error ¶
func (Error) GetMetricsFailureCategory ¶
func (e Error) GetMetricsFailureCategory() FailureCategory
GetMetricsFailureCategory get metrics status and error code corresponding to this error
func (Error) Unwrap ¶
Unwrap get underlying error
type FailureCategory ¶
FailureCategory sruct regrouping metrics failure status and specific exit code
func ByExitCode ¶
func ByExitCode(exitCode int) FailureCategory
ByExitCode retrieve FailureCategory based on command exit code
type Graph ¶
Graph represents project as service dependencies
func NewGraph ¶
func NewGraph(project *types.Project, initialStatus ServiceStatus) (*Graph, error)
NewGraph returns the dependency graph of the services
func (*Graph) AddEdge ¶
AddEdge adds a relationship of dependency between vertices `source` and `destination`
func (*Graph) AddVertex ¶
func (g *Graph) AddVertex(key string, service string, initialStatus ServiceStatus)
AddVertex adds a vertex to the Graph
func (*Graph) FilterChildren ¶
func (g *Graph) FilterChildren(key string, status ServiceStatus) []*Vertex
FilterChildren returns children of a certain vertex that are in a certain status
func (*Graph) FilterParents ¶
func (g *Graph) FilterParents(key string, status ServiceStatus) []*Vertex
FilterParents returns the parents of a certain vertex that are in a certain status
func (*Graph) HasCycles ¶
HasCycles detects cycles in the graph
func (*Graph) Leaves ¶
Leaves returns the slice of leaves of the graph
func (*Graph) Roots ¶
Roots returns the slice of "Roots" of the graph
func (*Graph) UpdateStatus ¶
func (g *Graph) UpdateStatus(key string, status ServiceStatus)
UpdateStatus updates the status of a certain vertex
type ImagePruneMode ¶
type ImagePruneMode string
ImagePruneMode controls how aggressively images associated with the project are removed from the engine.
const ( // ImagePruneNone indicates that no project images should be removed. ImagePruneNone ImagePruneMode = "" // ImagePruneLocal indicates that only images built locally by Compose // should be removed. ImagePruneLocal ImagePruneMode = "local" // ImagePruneAll indicates that all project-associated images, including // remote images should be removed. ImagePruneAll ImagePruneMode = "all" )
type ImagePruneOptions ¶
type ImagePruneOptions struct { Mode ImagePruneMode // RemoveOrphans will result in the removal of images that were built for // the project regardless of whether they are for a known service if true. RemoveOrphans bool }
ImagePruneOptions controls the behavior of image pruning.
type ImagePruner ¶
type ImagePruner struct {
// contains filtered or unexported fields
}
ImagePruner handles image removal during Compose `down` operations.
func NewImagePruner ¶
func NewImagePruner(imageClient client.ImageAPIClient, project *types.Project) *ImagePruner
NewImagePruner creates an ImagePruner object for a project.
func (*ImagePruner) ImagesToPrune ¶
func (p *ImagePruner) ImagesToPrune(ctx context.Context, opts ImagePruneOptions) ([]string, error)
ImagesToPrune returns the set of images that should be removed.
type ServiceStatus ¶
type ServiceStatus int
ServiceStatus indicates the status of a service
const ( ServiceStopped ServiceStatus = iota ServiceStarted )
Services status flags
type Trigger ¶
type Trigger struct { Path string `json:"path,omitempty"` Action string `json:"action,omitempty"` Target string `json:"target,omitempty"` Ignore []string `json:"ignore,omitempty"` }
type Vertex ¶
type Vertex struct { Key string Service string Status ServiceStatus Children map[string]*Vertex Parents map[string]*Vertex }
Vertex represents a service in the dependencies structure
func NewVertex ¶
func NewVertex(key string, service string, initialStatus ServiceStatus) *Vertex
NewVertex is the constructor function for the Vertex
func (*Vertex) GetChildren ¶
GetChildren returns a slice with the child vertices of the a Vertex
func (*Vertex) GetParents ¶
GetParents returns a slice with the parent vertices of the a Vertex
Source Files ¶
attach.go build.go build_buildkit.go build_classic.go compose.go container.go containers.go convergence.go convert.go cp.go create.go dependencies.go down.go envresolver.go errors.go events.go exec.go filters.go hash.go image_pruner.go images.go kill.go logs.go ls.go metrics.go pause.go port.go printer.go ps.go pull.go push.go remove.go restart.go run.go secrets.go start.go stop.go top.go up.go viz.go wait.go watch.go
- Version
- v2.20.2
- Published
- Jul 19, 2023
- Platform
- js/wasm
- Imports
- 94 packages
- Last checked
- 10 minutes ago –
Tools for package owners.