summaryrefslogtreecommitdiff
path: root/cmd/podman/common/volumes.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-29 08:26:05 -0400
committerGitHub <noreply@github.com>2020-05-29 08:26:05 -0400
commit78c38460eb8ba9190d414f2da6a1414990cc6cfd (patch)
tree2752ef254a80fad6844043210ee9c168832fe90f /cmd/podman/common/volumes.go
parent8e048b23fecbcf2140d1f0234d6067379d915953 (diff)
parente26f9eda64e4b74e1c56af0b807d37a12a1717a0 (diff)
downloadpodman-78c38460eb8ba9190d414f2da6a1414990cc6cfd.tar.gz
podman-78c38460eb8ba9190d414f2da6a1414990cc6cfd.tar.bz2
podman-78c38460eb8ba9190d414f2da6a1414990cc6cfd.zip
Merge pull request #6380 from mheon/fix_mount_readonly
Add support for `readonly` option to --mount
Diffstat (limited to 'cmd/podman/common/volumes.go')
-rw-r--r--cmd/podman/common/volumes.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/cmd/podman/common/volumes.go b/cmd/podman/common/volumes.go
index 6b0b6e9cf..a70410ad3 100644
--- a/cmd/podman/common/volumes.go
+++ b/cmd/podman/common/volumes.go
@@ -209,9 +209,29 @@ func getBindMount(args []string) (spec.Mount, error) {
switch kv[0] {
case "bind-nonrecursive":
newMount.Options = append(newMount.Options, "bind")
+ case "readonly", "read-only":
+ if setRORW {
+ return newMount, errors.Wrapf(optionArgError, "cannot pass 'readonly', 'ro', or 'rw' options more than once")
+ }
+ setRORW = true
+ switch len(kv) {
+ case 1:
+ newMount.Options = append(newMount.Options, "ro")
+ case 2:
+ switch strings.ToLower(kv[1]) {
+ case "true":
+ newMount.Options = append(newMount.Options, "ro")
+ case "false":
+ // RW is default, so do nothing
+ default:
+ return newMount, errors.Wrapf(optionArgError, "readonly must be set to true or false, instead received %q", kv[1])
+ }
+ default:
+ return newMount, errors.Wrapf(optionArgError, "badly formatted option %q", val)
+ }
case "ro", "rw":
if setRORW {
- return newMount, errors.Wrapf(optionArgError, "cannot pass 'ro' or 'rw' options more than once")
+ return newMount, errors.Wrapf(optionArgError, "cannot pass 'readonly', 'ro', or 'rw' options more than once")
}
setRORW = true
// Can be formatted as one of: