Fix compose volume creation and check this in volume e2e test

Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
This commit is contained in:
Guillaume Tardif 2020-12-07 16:41:54 +01:00
parent 6aec88e74c
commit fe363fd146
2 changed files with 27 additions and 17 deletions

View File

@ -1086,24 +1086,24 @@ func (s *composeService) ensureVolume(ctx context.Context, volume types.VolumeCo
// TODO could identify volume by label vs name // TODO could identify volume by label vs name
_, err := s.apiClient.VolumeInspect(ctx, volume.Name) _, err := s.apiClient.VolumeInspect(ctx, volume.Name)
if err != nil { if err != nil {
if errdefs.IsNotFound(err) { if !errdefs.IsNotFound(err) {
eventName := fmt.Sprintf("Volume %q", volume.Name) return err
w := progress.ContextWriter(ctx)
w.Event(progress.CreatingEvent(eventName))
// TODO we miss support for driver_opts and labels
_, err := s.apiClient.VolumeCreate(ctx, mobyvolume.VolumeCreateBody{
Labels: volume.Labels,
Name: volume.Name,
Driver: volume.Driver,
DriverOpts: volume.DriverOpts,
})
if err != nil {
w.Event(progress.ErrorEvent(eventName))
return err
}
w.Event(progress.CreatedEvent(eventName))
} }
return err eventName := fmt.Sprintf("Volume %q", volume.Name)
w := progress.ContextWriter(ctx)
w.Event(progress.CreatingEvent(eventName))
// TODO we miss support for driver_opts and labels
_, err := s.apiClient.VolumeCreate(ctx, mobyvolume.VolumeCreateBody{
Labels: volume.Labels,
Name: volume.Name,
Driver: volume.Driver,
DriverOpts: volume.DriverOpts,
})
if err != nil {
w.Event(progress.ErrorEvent(eventName))
return err
}
w.Event(progress.CreatedEvent(eventName))
} }
return nil return nil
} }

View File

@ -5,3 +5,13 @@ services:
- ./static:/usr/share/nginx/html - ./static:/usr/share/nginx/html
ports: ports:
- 8090:80 - 8090:80
nginx2:
build: nginx-build
volumes:
- staticVol:/usr/share/nginx/html
ports:
- 9090:80
volumes:
staticVol: