mirror of
https://github.com/docker/compose.git
synced 2026-11-28 02:49:57 +00:00
The packages extracted from pkg/compose (build, images, relay, containerops, logstream, devwatch, inspect, projectloader, publish, provider) each received the whole moby client through a single APIClient accessor, and the classic image build reached the daemon through the Docker CLI. Their Backend interfaces now ask for the client interfaces moby defines per resource (ContainerAPI, NetworkAPI, ImageAPI, ImageBuildAPI, ExecAPI, VolumeAPI, SystemAPI, DistributionAPI), and only for those the component calls: containerops works on containers alone, registry only resolves digests, and so on. The helpers they call (registry, desktop, the log stream monitor) take the matching family. composeService implements every accessor with its engine. composeService gets an optional engine field, used instead of the client of the Docker CLI when set. The CLI client still backs it by default, resolved on first use as before, since it initializes lazily. WithDryRun refuses a service holding an engine, as the dry-run client only wraps the CLI's one. Close releases the engine handed to the service, while the CLI's client stays with the CLI. No behavior change. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
48 lines
1.9 KiB
Go
48 lines
1.9 KiB
Go
/*
|
|
Copyright 2020 Docker Compose CLI authors
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
// Package engine describes what the operations extracted out of pkg/compose
|
|
// need from the engine they run against, so that they all state it the same way.
|
|
package engine
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/moby/moby/api/types/container"
|
|
)
|
|
|
|
// OneOff tells whether the containers of `compose run` are part of a listing.
|
|
type OneOff int
|
|
|
|
const (
|
|
// OneOffInclude lists the one-off containers along with the services' ones.
|
|
OneOffInclude OneOff = iota
|
|
// OneOffExclude leaves the one-off containers out.
|
|
OneOffExclude
|
|
)
|
|
|
|
// Backend is what every operation needs from the engine: the bound on the calls
|
|
// made to it, and the containers of a project. The calls themselves come from
|
|
// the families of the engine API each operation asks for in its own Backend.
|
|
type Backend interface {
|
|
// MaxConcurrency bounds the daemon calls made in parallel, 0 meaning no bound.
|
|
MaxConcurrency() int
|
|
// Containers lists the containers of a project, narrowed to services when given.
|
|
Containers(ctx context.Context, projectName string, oneOff OneOff, all bool, services ...string) ([]container.Summary, error)
|
|
// SpecifiedContainer returns the container of a service, the replica with
|
|
// the given index when it is above zero.
|
|
SpecifiedContainer(ctx context.Context, projectName string, oneOff OneOff, all bool, serviceName string, index int) (container.Summary, error)
|
|
}
|