diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-23 10:11:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-23 10:11:28 -0500 |
commit | 1702cbc6917f431bcc65d6c5bdc6fcf99231977a (patch) | |
tree | 2b138dda345970e5898593162c38e10d4909fabd /pkg/specgen | |
parent | 96fc9d983e0fc5bae48c3cec3acce86cdb6e1059 (diff) | |
parent | 874f2327e6ca963edda7cc46819d51048d3d19a8 (diff) | |
download | podman-1702cbc6917f431bcc65d6c5bdc6fcf99231977a.tar.gz podman-1702cbc6917f431bcc65d6c5bdc6fcf99231977a.tar.bz2 podman-1702cbc6917f431bcc65d6c5bdc6fcf99231977a.zip |
Merge pull request #8349 from EduardoVega/7778-chowning-based-on-uid
Add U volume flag to chown source volumes
Diffstat (limited to 'pkg/specgen')
-rw-r--r-- | pkg/specgen/generate/container_create.go | 5 | ||||
-rw-r--r-- | pkg/specgen/volumes.go | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go index 3b7112959..03697b353 100644 --- a/pkg/specgen/generate/container_create.go +++ b/pkg/specgen/generate/container_create.go @@ -247,8 +247,9 @@ func createContainerOptions(ctx context.Context, rt *libpod.Runtime, s *specgen. var vols []*libpod.ContainerOverlayVolume for _, v := range overlays { vols = append(vols, &libpod.ContainerOverlayVolume{ - Dest: v.Destination, - Source: v.Source, + Dest: v.Destination, + Source: v.Source, + Options: v.Options, }) } options = append(options, libpod.WithOverlayVolumes(vols)) diff --git a/pkg/specgen/volumes.go b/pkg/specgen/volumes.go index 83634b4ef..d85d2bdd1 100644 --- a/pkg/specgen/volumes.go +++ b/pkg/specgen/volumes.go @@ -31,6 +31,8 @@ type OverlayVolume struct { Destination string `json:"destination"` // Source specifies the source path of the mount. Source string `json:"source,omitempty"` + // Options holds overlay volume options. + Options []string `json:"options,omitempty"` } // ImageVolume is a volume based on a container image. The container image is @@ -100,10 +102,17 @@ func GenVolumeMounts(volumeFlag []string) (map[string]spec.Mount, map[string]*Na if strings.HasPrefix(src, "/") || strings.HasPrefix(src, ".") { // This is not a named volume overlayFlag := false + chownFlag := false for _, o := range options { if o == "O" { overlayFlag = true - if len(options) > 1 { + + joinedOpts := strings.Join(options, "") + if strings.Contains(joinedOpts, "U") { + chownFlag = true + } + + if len(options) > 2 || (len(options) == 2 && !chownFlag) { return nil, nil, nil, errors.New("can't use 'O' with other options") } } @@ -113,6 +122,8 @@ func GenVolumeMounts(volumeFlag []string) (map[string]spec.Mount, map[string]*Na newOverlayVol := new(OverlayVolume) newOverlayVol.Destination = cleanDest newOverlayVol.Source = src + newOverlayVol.Options = options + if _, ok := overlayVolumes[newOverlayVol.Destination]; ok { return nil, nil, nil, errors.Wrapf(errDuplicateDest, newOverlayVol.Destination) } |