Skip to content

Commit

Permalink
fix docker stack volume's nocopy parameter
Browse files Browse the repository at this point in the history
Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
  • Loading branch information
BSWANG committed Feb 15, 2017
1 parent ed003ff commit 4fe6119
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cli/compose/convert/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ func convertVolumeToMount(volumeSpec string, stackVolumes volumes, namespace Nam

var volumeOptions *mount.VolumeOptions
if stackVolume.External.Name != "" {
volumeOptions = &mount.VolumeOptions{
NoCopy: isNoCopy(mode),
}
source = stackVolume.External.Name
} else {
volumeOptions = &mount.VolumeOptions{
Expand Down
26 changes: 26 additions & 0 deletions cli/compose/convert/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,38 @@ func TestConvertVolumeToMountNamedVolumeExternal(t *testing.T) {
Type: mount.TypeVolume,
Source: "special",
Target: "/foo",
VolumeOptions: &mount.VolumeOptions{
NoCopy: false,
},
}
mount, err := convertVolumeToMount("outside:/foo", stackVolumes, namespace)
assert.NilError(t, err)
assert.DeepEqual(t, mount, expected)
}

func TestConvertVolumeToMountNamedVolumeExternalNoCopy(t *testing.T) {
stackVolumes := volumes{
"outside": composetypes.VolumeConfig{
External: composetypes.External{
External: true,
Name: "special",
},
},
}
namespace := NewNamespace("foo")
expected := mount.Mount{
Type: mount.TypeVolume,
Source: "special",
Target: "/foo",
VolumeOptions: &mount.VolumeOptions{
NoCopy: true,
},
}
mount, err := convertVolumeToMount("outside:/foo:nocopy", stackVolumes, namespace)
assert.NilError(t, err)
assert.DeepEqual(t, mount, expected)
}

func TestConvertVolumeToMountBind(t *testing.T) {
stackVolumes := volumes{}
namespace := NewNamespace("foo")
Expand Down

0 comments on commit 4fe6119

Please sign in to comment.