summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-05-26 00:04:46 -0400
committerMatthew Heon <mheon@redhat.com>2020-05-26 16:05:11 -0400
commite26f9eda64e4b74e1c56af0b807d37a12a1717a0 (patch)
treefc9a6578e97b0acf438af0f12343f78bffcff1ec /cmd/podman
parent1077d2d0b72d027a01080c0d3ebdb7d99a969661 (diff)
downloadpodman-e26f9eda64e4b74e1c56af0b807d37a12a1717a0.tar.gz
podman-e26f9eda64e4b74e1c56af0b807d37a12a1717a0.tar.bz2
podman-e26f9eda64e4b74e1c56af0b807d37a12a1717a0.zip
Add support for `readonly` option to --mount
This is just an alias to the `ro` option, but it's already in the manpages (and Docker) so we might as well add support for it. Fixes #6379 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'cmd/podman')
-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: