summaryrefslogtreecommitdiff
path: root/libpod
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 /libpod
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 'libpod')
-rw-r--r--libpod/runtime_ctr.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 8c3d283a5..f92898b1c 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -475,6 +475,26 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (_ *Contai
if isAnonymous {
volOptions = append(volOptions, withSetAnon())
}
+
+ // If volume-opts are set parse and add driver opts.
+ if len(vol.Options) > 0 {
+ isDriverOpts := false
+ driverOpts := make(map[string]string)
+ for _, opts := range vol.Options {
+ if strings.HasPrefix(opts, "volume-opt") {
+ isDriverOpts = true
+ driverOptKey, driverOptValue, err := util.ParseDriverOpts(opts)
+ if err != nil {
+ return nil, err
+ }
+ driverOpts[driverOptKey] = driverOptValue
+ }
+ }
+ if isDriverOpts {
+ parsedOptions := []VolumeCreateOption{WithVolumeOptions(driverOpts)}
+ volOptions = append(volOptions, parsedOptions...)
+ }
+ }
newVol, err := r.newVolume(ctx, volOptions...)
if err != nil {
return nil, errors.Wrapf(err, "error creating named volume %q", vol.Name)