mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Fixed incorrect docker mount arguments generation
The previous implementation combined --mount and -v notation of argument [1] adding :ro to make the read-only mount point. E.g. the command [2] called docker with the following params: [3]. As a result instead of the read-only folder /tmp/source, the read-write folder /tmp/source/:ro/' is created. This PR: 1. substitutes ':ro' with correct ',readonly'. 2. changes 'src=' and 'dst=' with 'source=' and 'target=' as it is stated in the documentation [1] 3. introduces the ability to EXPLICITLY create a mountpoint with read-write access. To do so it's necessary to add ',rw=true' to the --mount argument 4. corrects UTs adds some additional coverage for added functionality [1] https://docs.docker.com/storage/bind-mounts/#use-a-read-only-bind-mount [2] kustomize fn run ./d --mount type=bind,src=$(pwd)/test/,dst=/tmp/source/ [3] --mount type=bind,src=/home/ubuntu/kpt-functions-catalog/functions/ts/test/,dst=/tmp/source/:ro
This commit is contained in:
@@ -73,14 +73,16 @@ metadata:
|
||||
"--network", "none",
|
||||
"--user", "nobody",
|
||||
"--security-opt=no-new-privileges",
|
||||
"--mount", fmt.Sprintf("type=%s,src=%s,dst=%s:ro", "bind", "/mount/path", "/local/"),
|
||||
"--mount", fmt.Sprintf("type=%s,src=%s,dst=%s:ro", "volume", "myvol", "/local/"),
|
||||
"--mount", fmt.Sprintf("type=%s,src=%s,dst=%s:ro", "tmpfs", "", "/local/"),
|
||||
"--mount", fmt.Sprintf("type=%s,source=%s,target=%s,readonly", "bind", "/mount/path", "/local/"),
|
||||
"--mount", fmt.Sprintf("type=%s,source=%s,target=%s", "bind", "/mount/pathrw", "/localrw/"),
|
||||
"--mount", fmt.Sprintf("type=%s,source=%s,target=%s,readonly", "volume", "myvol", "/local/"),
|
||||
"--mount", fmt.Sprintf("type=%s,source=%s,target=%s,readonly", "tmpfs", "", "/local/"),
|
||||
},
|
||||
instance: Filter{
|
||||
Image: "example.com:version",
|
||||
StorageMounts: []runtimeutil.StorageMount{
|
||||
{MountType: "bind", Src: "/mount/path", DstPath: "/local/"},
|
||||
{MountType: "bind", Src: "/mount/pathrw", DstPath: "/localrw/", ReadWriteMode: true},
|
||||
{MountType: "volume", Src: "myvol", DstPath: "/local/"},
|
||||
{MountType: "tmpfs", Src: "", DstPath: "/local/"},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user