Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combine the code of dealing with 'readonly' and 'ro'. #6443

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 7 additions & 22 deletions cmd/podman/common/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,36 +209,21 @@ 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":
case "readonly", "ro", "rw":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't read-only still need to be here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tom, thanks for asking.

read-only was in the manual, but this option had never been implemented in the code before.

mheon replaced read-only with readonly in the manual (#6380), I went ahead and removed read-only from the code. As the final result, the readonly is in the manual and code, the same behavior as Docker.

Have a nice day.
Charles

if setRORW {
return newMount, errors.Wrapf(optionArgError, "cannot pass 'readonly', 'ro', or 'rw' options more than once")
}
setRORW = true
// Can be formatted as one of:
// readonly
// readonly=[true|false]
// ro
// ro=[true|false]
// rw
// rw=[true|false]
if kv[0] == "readonly" {
kv[0] = "ro"
}
switch len(kv) {
case 1:
newMount.Options = append(newMount.Options, kv[0])
Expand All @@ -253,7 +238,7 @@ func getBindMount(args []string) (spec.Mount, error) {
newMount.Options = append(newMount.Options, "ro")
}
default:
return newMount, errors.Wrapf(optionArgError, "%s must be set to true or false, instead received %q", kv[0], kv[1])
return newMount, errors.Wrapf(optionArgError, "'readonly', 'ro', or 'rw' must be set to true or false, instead received %q", kv[1])
}
default:
return newMount, errors.Wrapf(optionArgError, "badly formatted option %q", val)
Expand Down