mirror of
https://github.com/docker/compose.git
synced 2026-11-21 07:30:30 +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>
47 lines
1.4 KiB
Go
47 lines
1.4 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
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/docker/cli/cli/command/container"
|
|
|
|
"github.com/docker/compose/v5/internal/engine"
|
|
"github.com/docker/compose/v5/pkg/api"
|
|
)
|
|
|
|
// Attach attaches the terminal to the container of a service.
|
|
func (s *Service) Attach(ctx context.Context, projectName string, options api.AttachOptions) error {
|
|
projectName = strings.ToLower(projectName)
|
|
target, err := s.backend.SpecifiedContainer(ctx, projectName, engine.OneOffInclude, false, options.Service, options.Index)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
detachKeys := options.DetachKeys
|
|
if detachKeys == "" {
|
|
detachKeys = s.backend.CLI().ConfigFile().DetachKeys
|
|
}
|
|
|
|
var attach container.AttachOptions
|
|
attach.DetachKeys = detachKeys
|
|
attach.NoStdin = options.NoStdin
|
|
attach.Proxy = options.Proxy
|
|
return container.RunAttach(ctx, s.backend.CLI(), target.ID, &attach)
|
|
}
|