compose/internal/containerops/containerops.go
Nicolas De Loof 117374692c refactor(compose): share the bounded per-container fan-out
internal/containerops and pkg/compose both had a copy of forEachContainerConcurrent. Provide it once, generic, in internal/concurrency.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2026-10-29 11:59:43 +01:00

52 lines
1.7 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 containerops implements the operations that act from the outside on
// the container of a service: exec, cp, export and commit.
package containerops
import (
"github.com/docker/cli/cli/command"
"github.com/docker/compose/v5/internal/engine"
"github.com/docker/compose/v5/pkg/api"
)
// Backend is what the operations need from the engine they act on.
//
// The terminal reaches them through CLI: stdin, stdout and the TTY all come
// from the Docker CLI's streams, the one seam through which an operation that
// talks to the user does so (exec hands the whole CLI to the Docker CLI's own
// implementation).
type Backend interface {
engine.Backend
// Events receives the progress of the operations.
Events() api.EventProcessor
// DryRun tells whether the operations only report what they would do.
DryRun() bool
// CLI is the Docker CLI Compose runs in, and the owner of the terminal streams.
CLI() command.Cli
}
// Service runs the container operations on a Backend.
type Service struct {
backend Backend
}
// New creates a Service acting on the given Backend.
func New(backend Backend) *Service {
return &Service{backend: backend}
}