1
0
mirror of https://github.com/docker/compose.git synced 2025-04-08 17:05:13 +02:00

report docker resources creation in progress

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-11-16 09:51:45 +01:00
parent 7944a1b94f
commit 0d33e5cdcc
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E

@ -77,6 +77,13 @@ func (s *local) Up(ctx context.Context, project *types.Project, detach bool) err
if err != nil {
return err
}
w := progress.ContextWriter(ctx)
w.Event(progress.Event{
ID: fmt.Sprintf("Service %q", service.Name),
Status: progress.Working,
StatusText: "Create",
Done: false,
})
name := fmt.Sprintf("%s_%s", project.Name, service.Name)
id, err := s.containerService.create(ctx, containerConfig, hostConfig, networkingConfig, name)
if err != nil {
@ -89,10 +96,22 @@ func (s *local) Up(ctx context.Context, project *types.Project, detach bool) err
return err
}
}
w.Event(progress.Event{
ID: fmt.Sprintf("Service %q", service.Name),
Status: progress.Working,
StatusText: "Start",
Done: false,
})
err = s.containerService.apiClient.ContainerStart(ctx, id, moby.ContainerStartOptions{})
if err != nil {
return err
}
w.Event(progress.Event{
ID: fmt.Sprintf("Service %q", service.Name),
Status: progress.Done,
StatusText: "Started",
Done: true,
})
}
return nil
}
@ -488,9 +507,22 @@ func (s *local) ensureNetwork(ctx context.Context, n types.NetworkConfig) error
}
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
}
w := progress.ContextWriter(ctx)
w.Event(progress.Event{
ID: fmt.Sprintf("Network %q", n.Name),
Status: progress.Working,
StatusText: "Create",
Done: false,
})
if _, err := s.containerService.apiClient.NetworkCreate(context.Background(), n.Name, createOpts); err != nil {
return errors.Wrapf(err, "failed to create network %s", n.Name)
}
w.Event(progress.Event{
ID: fmt.Sprintf("Network %q", n.Name),
Status: progress.Working,
StatusText: "Created",
Done: true,
})
return nil
} else {
return err
@ -514,8 +546,21 @@ func (s *local) ensureVolume(ctx context.Context, volume types.VolumeConfig) err
_, err := s.volumeService.Inspect(ctx, volume.Name)
if err != nil {
if errdefs.IsNotFound(err) {
w := progress.ContextWriter(ctx)
w.Event(progress.Event{
ID: fmt.Sprintf("Volume %q", volume.Name),
Status: progress.Working,
StatusText: "Create",
Done: false,
})
// TODO we miss support for driver_opts and labels
_, err := s.volumeService.Create(ctx, volume.Name, nil)
w.Event(progress.Event{
ID: fmt.Sprintf("Volume %q", volume.Name),
Status: progress.Done,
StatusText: "Created",
Done: true,
})
if err != nil {
return err
}