Signed-off-by: bingshen.wbs <bingshen.wbs@alibaba-inc.com>
| ... | ... |
@@ -75,6 +75,9 @@ func convertVolumeToMount(volumeSpec string, stackVolumes volumes, namespace Nam |
| 75 | 75 |
|
| 76 | 76 |
var volumeOptions *mount.VolumeOptions |
| 77 | 77 |
if stackVolume.External.Name != "" {
|
| 78 |
+ volumeOptions = &mount.VolumeOptions{
|
|
| 79 |
+ NoCopy: isNoCopy(mode), |
|
| 80 |
+ } |
|
| 78 | 81 |
source = stackVolume.External.Name |
| 79 | 82 |
} else {
|
| 80 | 83 |
volumeOptions = &mount.VolumeOptions{
|
| ... | ... |
@@ -105,12 +105,38 @@ func TestConvertVolumeToMountNamedVolumeExternal(t *testing.T) {
|
| 105 | 105 |
Type: mount.TypeVolume, |
| 106 | 106 |
Source: "special", |
| 107 | 107 |
Target: "/foo", |
| 108 |
+ VolumeOptions: &mount.VolumeOptions{
|
|
| 109 |
+ NoCopy: false, |
|
| 110 |
+ }, |
|
| 108 | 111 |
} |
| 109 | 112 |
mount, err := convertVolumeToMount("outside:/foo", stackVolumes, namespace)
|
| 110 | 113 |
assert.NilError(t, err) |
| 111 | 114 |
assert.DeepEqual(t, mount, expected) |
| 112 | 115 |
} |
| 113 | 116 |
|
| 117 |
+func TestConvertVolumeToMountNamedVolumeExternalNoCopy(t *testing.T) {
|
|
| 118 |
+ stackVolumes := volumes{
|
|
| 119 |
+ "outside": composetypes.VolumeConfig{
|
|
| 120 |
+ External: composetypes.External{
|
|
| 121 |
+ External: true, |
|
| 122 |
+ Name: "special", |
|
| 123 |
+ }, |
|
| 124 |
+ }, |
|
| 125 |
+ } |
|
| 126 |
+ namespace := NewNamespace("foo")
|
|
| 127 |
+ expected := mount.Mount{
|
|
| 128 |
+ Type: mount.TypeVolume, |
|
| 129 |
+ Source: "special", |
|
| 130 |
+ Target: "/foo", |
|
| 131 |
+ VolumeOptions: &mount.VolumeOptions{
|
|
| 132 |
+ NoCopy: true, |
|
| 133 |
+ }, |
|
| 134 |
+ } |
|
| 135 |
+ mount, err := convertVolumeToMount("outside:/foo:nocopy", stackVolumes, namespace)
|
|
| 136 |
+ assert.NilError(t, err) |
|
| 137 |
+ assert.DeepEqual(t, mount, expected) |
|
| 138 |
+} |
|
| 139 |
+ |
|
| 114 | 140 |
func TestConvertVolumeToMountBind(t *testing.T) {
|
| 115 | 141 |
stackVolumes := volumes{}
|
| 116 | 142 |
namespace := NewNamespace("foo")
|