aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorAditya R <arajan@redhat.com>2022-04-06 15:59:59 +0530
committerAditya R <arajan@redhat.com>2022-04-12 12:30:09 +0530
commit81a95fade593d4fda6c6f340865ae24824ac2ac8 (patch)
tree10d3ba6bb26048bf270866534892f8c29262608e /pkg
parent8b6f911e4818d02bca65ff263dcb61bfe082a470 (diff)
downloadpodman-81a95fade593d4fda6c6f340865ae24824ac2ac8.tar.gz
podman-81a95fade593d4fda6c6f340865ae24824ac2ac8.tar.bz2
podman-81a95fade593d4fda6c6f340865ae24824ac2ac8.zip
run, mount: allow setting driver specific option using volume-opt
`--mount` should allow setting driver specific options using `volume-opt` when `type=volume` is set. This ensures parity with docker's `volume-opt`. Signed-off-by: Aditya R <arajan@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r--pkg/specgenutil/volumes.go2
-rw-r--r--pkg/util/mountOpts.go15
2 files changed, 17 insertions, 0 deletions
diff --git a/pkg/specgenutil/volumes.go b/pkg/specgenutil/volumes.go
index 8a861077a..aa07de0af 100644
--- a/pkg/specgenutil/volumes.go
+++ b/pkg/specgenutil/volumes.go
@@ -523,6 +523,8 @@ func getNamedVolume(args []string) (*specgen.NamedVolume, error) {
for _, val := range args {
kv := strings.SplitN(val, "=", 2)
switch kv[0] {
+ case "volume-opt":
+ newVolume.Options = append(newVolume.Options, val)
case "ro", "rw":
if setRORW {
return nil, errors.Wrapf(optionArgError, "cannot pass 'ro' and 'rw' options more than once")
diff --git a/pkg/util/mountOpts.go b/pkg/util/mountOpts.go
index 2a0101791..e37394619 100644
--- a/pkg/util/mountOpts.go
+++ b/pkg/util/mountOpts.go
@@ -57,6 +57,9 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string
switch splitOpt[0] {
case "O":
foundOverlay = true
+ case "volume-opt":
+ // Volume-opt should be relayed and processed by driver.
+ newOptions = append(newOptions, opt)
case "exec", "noexec":
if foundExec {
return nil, errors.Wrapf(ErrDupeMntOption, "only one of 'noexec' and 'exec' can be used")
@@ -175,3 +178,15 @@ func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string
return newOptions, nil
}
+
+func ParseDriverOpts(option string) (string, string, error) {
+ token := strings.SplitN(option, "=", 2)
+ if len(token) != 2 {
+ return "", "", errors.Wrapf(ErrBadMntOption, "cannot parse driver opts")
+ }
+ opt := strings.SplitN(token[1], "=", 2)
+ if len(opt) != 2 {
+ return "", "", errors.Wrapf(ErrBadMntOption, "cannot parse driver opts")
+ }
+ return opt[0], opt[1], nil
+}