mirror of
https://github.com/docker/compose.git
synced 2026-11-20 15:09:50 +00:00
Some checks are pending
ci / validate (lint) (push) Waiting to run
ci / validate (relay-lint) (push) Waiting to run
ci / validate (relay-test) (push) Waiting to run
ci / validate (validate-docs) (push) Waiting to run
ci / validate (validate-go-mod) (push) Waiting to run
ci / validate (validate-headers) (push) Waiting to run
ci / validate (validate-mocks) (push) Waiting to run
ci / binary (push) Waiting to run
ci / binary-finalize (push) Blocked by required conditions
ci / bin-image-test (push) Waiting to run
ci / relay-image-test (push) Waiting to run
ci / test (push) Waiting to run
ci / e2e (plugin, oldstable, graphdriver) (push) Waiting to run
ci / e2e (standalone, oldstable, graphdriver) (push) Waiting to run
ci / e2e (plugin, stable, containerd) (push) Waiting to run
ci / e2e (plugin, stable, graphdriver) (push) Waiting to run
ci / e2e (standalone, stable, containerd) (push) Waiting to run
ci / e2e (standalone, stable, graphdriver) (push) Waiting to run
ci / coverage (push) Blocked by required conditions
ci / ci-ok (push) Blocked by required conditions
ci / release (push) Blocked by required conditions
merge / bin-image-prepare (push) Waiting to run
merge / bin-image (push) Blocked by required conditions
merge / relay-image (push) Waiting to run
merge / module-image (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
zizmor / zizmor (push) Waiting to run
logs, attach, the container event monitor they follow and the log printer move to internal/logstream. The package declares what it needs from the engine as a small Backend interface; composeService implements it and keeps one-line forwarders, so `up` and the other callers are unchanged. Behavior is unchanged: the tests that exercise the moved code keep their assertions. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
55 lines
1.6 KiB
Go
55 lines
1.6 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 logstream streams the output of the containers of a project to the
|
|
// user: logs, attach, and the monitor of the containers' events they follow.
|
|
package logstream
|
|
|
|
import (
|
|
"github.com/docker/cli/cli/command"
|
|
|
|
"github.com/docker/compose/v5/internal/engine"
|
|
"github.com/docker/compose/v5/internal/naming"
|
|
"github.com/docker/compose/v5/pkg/api"
|
|
)
|
|
|
|
// Backend is what the operations need from the engine they stream from.
|
|
//
|
|
// The terminal reaches them through CLI: the stream attach prints its
|
|
// announcement to, and the Docker CLI's own attach implementation.
|
|
type Backend interface {
|
|
engine.Backend
|
|
// CLI is the Docker CLI Compose runs in, and the owner of the terminal streams.
|
|
CLI() command.Cli
|
|
}
|
|
|
|
// Service streams the containers' output on a Backend.
|
|
type Service struct {
|
|
backend Backend
|
|
}
|
|
|
|
// New creates a Service streaming from the given Backend.
|
|
func New(backend Backend) *Service {
|
|
return &Service{backend: backend}
|
|
}
|
|
|
|
func oneOffFilter(b bool) string {
|
|
v := "False"
|
|
if b {
|
|
v = "True"
|
|
}
|
|
return naming.LabelFilter(api.OneoffLabel, v)
|
|
}
|