Made mountString params more similar to docker params

see [1]
kept support for the previous field names similarly to
docker behavior.

[1]
https://docs.docker.com/storage/bind-mounts/#use-a-read-only-bind-mount
This commit is contained in:
Alexey Odinokov
2020-07-13 17:21:37 +00:00
parent 63f9f79fc0
commit ba3e09849a
2 changed files with 10 additions and 2 deletions

View File

@@ -166,9 +166,9 @@ func StringToStorageMount(s string) StorageMount {
switch {
case key == "type":
sm.MountType = value
case key == "src":
case key == "src" || key == "source":
sm.Src = value
case key == "dst":
case key == "dst" || key == "target":
sm.DstPath = value
case key == "rw" && value == "true":
sm.ReadWriteMode = true

View File

@@ -1413,6 +1413,14 @@ func Test_StringToStorageMount(t *testing.T) {
in: "type=tmpfs,src=/tmp/test/,dst",
expectedOut: "type=tmpfs,source=/tmp/test/,target=,readonly",
},
{
in: "type=bind,source=/tmp/test/,target=/tmp/source/,rw=true",
expectedOut: "type=bind,source=/tmp/test/,target=/tmp/source/",
},
{
in: "type=bind,source=/tmp/test/,target=/tmp/source/",
expectedOut: "type=bind,source=/tmp/test/,target=/tmp/source/,readonly",
},
}
for _, tc := range tests {