mirror of https://github.com/docker/compose.git
Add support for volume Subpath option
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
3b541b071c
commit
3950460703
|
@ -1136,7 +1136,8 @@ func buildVolumeOptions(vol *types.ServiceVolumeVolume) *mount.VolumeOptions {
|
|||
return nil
|
||||
}
|
||||
return &mount.VolumeOptions{
|
||||
NoCopy: vol.NoCopy,
|
||||
NoCopy: vol.NoCopy,
|
||||
Subpath: vol.Subpath,
|
||||
// Labels: , // FIXME missing from model ?
|
||||
// DriverConfig: , // FIXME missing from model ?
|
||||
}
|
||||
|
|
|
@ -113,6 +113,14 @@ func TestBuildContainerMountOptions(t *testing.T) {
|
|||
Type: composetypes.VolumeTypeVolume,
|
||||
Target: "/var/myvolume2",
|
||||
},
|
||||
{
|
||||
Type: composetypes.VolumeTypeVolume,
|
||||
Source: "myVolume3",
|
||||
Target: "/var/myvolume3",
|
||||
Volume: &composetypes.ServiceVolumeVolume{
|
||||
Subpath: "etc",
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: composetypes.VolumeTypeNamedPipe,
|
||||
Source: "\\\\.\\pipe\\docker_engine_windows",
|
||||
|
@ -149,20 +157,24 @@ func TestBuildContainerMountOptions(t *testing.T) {
|
|||
return mounts[i].Target < mounts[j].Target
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, len(mounts) == 3)
|
||||
assert.Assert(t, len(mounts) == 4)
|
||||
assert.Equal(t, mounts[0].Target, "/var/myvolume1")
|
||||
assert.Equal(t, mounts[1].Target, "/var/myvolume2")
|
||||
assert.Equal(t, mounts[2].Target, "\\\\.\\pipe\\docker_engine")
|
||||
assert.Equal(t, mounts[2].Target, "/var/myvolume3")
|
||||
assert.Equal(t, mounts[2].VolumeOptions.Subpath, "etc")
|
||||
assert.Equal(t, mounts[3].Target, "\\\\.\\pipe\\docker_engine")
|
||||
|
||||
mounts, err = buildContainerMountOptions(project, project.Services["myService"], moby.ImageInspect{}, inherit)
|
||||
sort.Slice(mounts, func(i, j int) bool {
|
||||
return mounts[i].Target < mounts[j].Target
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
assert.Assert(t, len(mounts) == 3)
|
||||
assert.Assert(t, len(mounts) == 4)
|
||||
assert.Equal(t, mounts[0].Target, "/var/myvolume1")
|
||||
assert.Equal(t, mounts[1].Target, "/var/myvolume2")
|
||||
assert.Equal(t, mounts[2].Target, "\\\\.\\pipe\\docker_engine")
|
||||
assert.Equal(t, mounts[2].Target, "/var/myvolume3")
|
||||
assert.Equal(t, mounts[2].VolumeOptions.Subpath, "etc")
|
||||
assert.Equal(t, mounts[3].Target, "\\\\.\\pipe\\docker_engine")
|
||||
}
|
||||
|
||||
func TestDefaultNetworkSettings(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue