diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-12 13:17:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 13:17:02 -0400 |
commit | 87d129e805c993acbc571597baba8101afd475fe (patch) | |
tree | 9e549bdb44bdace7ad62d7efe6123377e2df7ee8 /libpod/runtime_ctr.go | |
parent | db7cd88c6781c3d42376f02b5b1547c466c45d3e (diff) | |
parent | 81a95fade593d4fda6c6f340865ae24824ac2ac8 (diff) | |
download | podman-87d129e805c993acbc571597baba8101afd475fe.tar.gz podman-87d129e805c993acbc571597baba8101afd475fe.tar.bz2 podman-87d129e805c993acbc571597baba8101afd475fe.zip |
Merge pull request #13788 from flouthoc/support-volume-opts
run, mount: allow setting driver specific option using `volume-opt=`
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r-- | libpod/runtime_ctr.go | 20 |
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) |