mirror of https://github.com/docker/cli.git
fix docker stack volume's nocopy parameter
Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
This commit is contained in:
parent
6cae9ce20b
commit
6887337d86
|
@ -75,6 +75,9 @@ func convertVolumeToMount(volumeSpec string, stackVolumes volumes, namespace Nam
|
||||||
|
|
||||||
var volumeOptions *mount.VolumeOptions
|
var volumeOptions *mount.VolumeOptions
|
||||||
if stackVolume.External.Name != "" {
|
if stackVolume.External.Name != "" {
|
||||||
|
volumeOptions = &mount.VolumeOptions{
|
||||||
|
NoCopy: isNoCopy(mode),
|
||||||
|
}
|
||||||
source = stackVolume.External.Name
|
source = stackVolume.External.Name
|
||||||
} else {
|
} else {
|
||||||
volumeOptions = &mount.VolumeOptions{
|
volumeOptions = &mount.VolumeOptions{
|
||||||
|
|
|
@ -105,12 +105,38 @@ func TestConvertVolumeToMountNamedVolumeExternal(t *testing.T) {
|
||||||
Type: mount.TypeVolume,
|
Type: mount.TypeVolume,
|
||||||
Source: "special",
|
Source: "special",
|
||||||
Target: "/foo",
|
Target: "/foo",
|
||||||
|
VolumeOptions: &mount.VolumeOptions{
|
||||||
|
NoCopy: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
mount, err := convertVolumeToMount("outside:/foo", stackVolumes, namespace)
|
mount, err := convertVolumeToMount("outside:/foo", stackVolumes, namespace)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.DeepEqual(t, mount, expected)
|
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) {
|
func TestConvertVolumeToMountBind(t *testing.T) {
|
||||||
stackVolumes := volumes{}
|
stackVolumes := volumes{}
|
||||||
namespace := NewNamespace("foo")
|
namespace := NewNamespace("foo")
|
||||||
|
|
Loading…
Reference in New Issue