mirror of
https://github.com/docker/compose.git
synced 2026-02-09 10:09:26 +08:00
committed by
Guillaume Lours
parent
8619f5d72a
commit
ac3b8fd8a5
@@ -45,7 +45,7 @@ func (s *composeService) useAPISocket(project *types.Project) (*types.Project, e
|
||||
return nil, errors.New("use_api_socket can't be used with a Windows Docker Engine")
|
||||
}
|
||||
|
||||
creds, err := s.dockerCli.ConfigFile().GetAllCredentials()
|
||||
creds, err := s.configFile().GetAllCredentials()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("resolving credentials failed: %w", err)
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ func (s *composeService) commit(ctx context.Context, projectName string, options
|
||||
return err
|
||||
}
|
||||
|
||||
clnt := s.dockerCli.Client()
|
||||
clnt := s.apiClient()
|
||||
|
||||
w := progress.ContextWriter(ctx)
|
||||
|
||||
|
||||
@@ -92,7 +92,7 @@ type composeService struct {
|
||||
func (s *composeService) Close() error {
|
||||
var errs []error
|
||||
if s.dockerCli != nil {
|
||||
errs = append(errs, s.dockerCli.Client().Close())
|
||||
errs = append(errs, s.apiClient().Close())
|
||||
}
|
||||
return errors.Join(errs...)
|
||||
}
|
||||
@@ -323,7 +323,7 @@ var runtimeVersion runtimeVersionCache
|
||||
|
||||
func (s *composeService) RuntimeVersion(ctx context.Context) (string, error) {
|
||||
runtimeVersion.once.Do(func() {
|
||||
version, err := s.dockerCli.Client().ServerVersion(ctx)
|
||||
version, err := s.apiClient().ServerVersion(ctx)
|
||||
if err != nil {
|
||||
runtimeVersion.err = err
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (s *composeService) export(ctx context.Context, projectName string, options
|
||||
return fmt.Errorf("failed to export container: %w", err)
|
||||
}
|
||||
|
||||
clnt := s.dockerCli.Client()
|
||||
clnt := s.apiClient()
|
||||
|
||||
w := progress.ContextWriter(ctx)
|
||||
|
||||
|
||||
@@ -90,8 +90,7 @@ func (s *composeService) publish(ctx context.Context, project *types.Project, re
|
||||
return err
|
||||
}
|
||||
|
||||
config := s.dockerCli.ConfigFile()
|
||||
resolver := oci.NewResolver(config)
|
||||
resolver := oci.NewResolver(s.configFile())
|
||||
|
||||
descriptor, err := oci.PushManifest(ctx, resolver, named, layers, options.OCIVersion)
|
||||
if err != nil {
|
||||
|
||||
@@ -116,7 +116,7 @@ func (s *composeService) pull(ctx context.Context, project *types.Project, opts
|
||||
|
||||
idx := i
|
||||
eg.Go(func() error {
|
||||
_, err := s.pullServiceImage(ctx, service, s.configFile(), w, opts.Quiet, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
||||
_, err := s.pullServiceImage(ctx, service, w, opts.Quiet, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
||||
if err != nil {
|
||||
pullErrors[idx] = err
|
||||
if service.Build != nil {
|
||||
@@ -177,9 +177,7 @@ func getUnwrappedErrorMessage(err error) string {
|
||||
return err.Error()
|
||||
}
|
||||
|
||||
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig,
|
||||
configFile driver.Auth, w progress.Writer, quietPull bool, defaultPlatform string,
|
||||
) (string, error) {
|
||||
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig, w progress.Writer, quietPull bool, defaultPlatform string) (string, error) {
|
||||
w.Event(progress.Event{
|
||||
ID: service.Name,
|
||||
Status: progress.Working,
|
||||
@@ -190,7 +188,7 @@ func (s *composeService) pullServiceImage(ctx context.Context, service types.Ser
|
||||
return "", err
|
||||
}
|
||||
|
||||
encodedAuth, err := encodedAuth(ref, configFile)
|
||||
encodedAuth, err := encodedAuth(ref, s.configFile())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -330,7 +328,7 @@ func (s *composeService) pullRequiredImages(ctx context.Context, project *types.
|
||||
var mutex sync.Mutex
|
||||
for name, service := range needPull {
|
||||
eg.Go(func() error {
|
||||
id, err := s.pullServiceImage(ctx, service, s.configFile(), w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
||||
id, err := s.pullServiceImage(ctx, service, w, quietPull, project.Environment["DOCKER_DEFAULT_PLATFORM"])
|
||||
mutex.Lock()
|
||||
defer mutex.Unlock()
|
||||
pulledImages[name] = api.ImageSummary{
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
|
||||
"github.com/compose-spec/compose-go/v2/types"
|
||||
"github.com/distribution/reference"
|
||||
"github.com/docker/buildx/driver"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@@ -70,7 +69,7 @@ func (s *composeService) push(ctx context.Context, project *types.Project, optio
|
||||
|
||||
for _, tag := range tags {
|
||||
eg.Go(func() error {
|
||||
err := s.pushServiceImage(ctx, tag, s.configFile(), w, options.Quiet)
|
||||
err := s.pushServiceImage(ctx, tag, w, options.Quiet)
|
||||
if err != nil {
|
||||
if !options.IgnoreFailures {
|
||||
return err
|
||||
@@ -84,13 +83,13 @@ func (s *composeService) push(ctx context.Context, project *types.Project, optio
|
||||
return eg.Wait()
|
||||
}
|
||||
|
||||
func (s *composeService) pushServiceImage(ctx context.Context, tag string, configFile driver.Auth, w progress.Writer, quietPush bool) error {
|
||||
func (s *composeService) pushServiceImage(ctx context.Context, tag string, w progress.Writer, quietPush bool) error {
|
||||
ref, err := reference.ParseNormalizedNamed(tag)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
authConfig, err := configFile.GetAuthConfig(registry.GetAuthConfigKey(reference.Domain(ref)))
|
||||
authConfig, err := s.configFile().GetAuthConfig(registry.GetAuthConfigKey(reference.Domain(ref)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func (s *composeService) Wait(ctx context.Context, projectName string, options a
|
||||
for _, ctr := range containers {
|
||||
eg.Go(func() error {
|
||||
var err error
|
||||
resultC, errC := s.dockerCli.Client().ContainerWait(waitCtx, ctr.ID, "")
|
||||
resultC, errC := s.apiClient().ContainerWait(waitCtx, ctr.ID, "")
|
||||
|
||||
select {
|
||||
case result := <-resultC:
|
||||
|
||||
Reference in New Issue
Block a user