From ba3e09849a8faddf93306f15ec58f5638c77b520 Mon Sep 17 00:00:00 2001 From: Alexey Odinokov Date: Mon, 13 Jul 2020 17:21:37 +0000 Subject: [PATCH] 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 --- kyaml/fn/runtime/runtimeutil/functiontypes.go | 4 ++-- kyaml/fn/runtime/runtimeutil/runtimeutil_test.go | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/kyaml/fn/runtime/runtimeutil/functiontypes.go b/kyaml/fn/runtime/runtimeutil/functiontypes.go index 9bd396d30..6e476e871 100644 --- a/kyaml/fn/runtime/runtimeutil/functiontypes.go +++ b/kyaml/fn/runtime/runtimeutil/functiontypes.go @@ -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 diff --git a/kyaml/fn/runtime/runtimeutil/runtimeutil_test.go b/kyaml/fn/runtime/runtimeutil/runtimeutil_test.go index cbffcf042..89b728cf1 100644 --- a/kyaml/fn/runtime/runtimeutil/runtimeutil_test.go +++ b/kyaml/fn/runtime/runtimeutil/runtimeutil_test.go @@ -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 {