ignore services without image attribute

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2021-01-04 16:08:27 +01:00
parent b560f0cbe9
commit 5a455e47c3
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
2 changed files with 66 additions and 48 deletions

View File

@ -55,6 +55,14 @@ func (s *composeService) Pull(ctx context.Context, project *types.Project) error
for _, srv := range project.Services {
service := srv
if service.Image == "" {
w.Event(progress.Event{
ID: service.Name,
Status: progress.Done,
Text: "Skipped",
})
continue
}
eg.Go(func() error {
w.Event(progress.Event{
ID: service.Name,

View File

@ -23,6 +23,8 @@ import (
"fmt"
"io"
"github.com/docker/buildx/driver"
"github.com/docker/compose-cli/config"
"github.com/docker/compose-cli/progress"
@ -51,14 +53,25 @@ func (s *composeService) Push(ctx context.Context, project *types.Project) error
info.IndexServerAddress = registry.IndexServer
}
w := progress.ContextWriter(ctx)
for _, service := range project.Services {
if service.Build == nil {
if service.Build == nil || service.Image == "" {
w.Event(progress.Event{
ID: service.Name,
Status: progress.Done,
Text: "Skipped",
})
continue
}
service := service
eg.Go(func() error {
w := progress.ContextWriter(ctx)
return s.pullServiceImage(ctx, service, info, configFile, w)
})
}
return eg.Wait()
}
func (s *composeService) pullServiceImage(ctx context.Context, service types.ServiceConfig, info moby.Info, configFile driver.Auth, w progress.Writer) error {
ref, err := reference.ParseNormalizedNamed(service.Image)
if err != nil {
return err
@ -104,9 +117,6 @@ func (s *composeService) Push(ctx context.Context, project *types.Project) error
toPushProgressEvent("Pushing "+service.Name, jm, w)
}
return nil
})
}
return eg.Wait()
}
func toPushProgressEvent(prefix string, jm jsonmessage.JSONMessage, w progress.Writer) {