mirror of
https://github.com/containers/podman.git
synced 2025-12-12 17:57:31 +08:00
Merge pull request #16803 from cdoern/subpath
add support for subpath in play kube for named volumes
This commit is contained in:
@@ -254,6 +254,8 @@ type ContainerNamedVolume struct {
|
||||
// IsAnonymous sets the named volume as anonymous even if it has a name
|
||||
// This is used for emptyDir volumes from a kube yaml
|
||||
IsAnonymous bool `json:"setAnonymous,omitempty"`
|
||||
// SubPath determines which part of the Source will be mounted in the container
|
||||
SubPath string
|
||||
}
|
||||
|
||||
// ContainerOverlayVolume is an overlay volume that will be mounted into the
|
||||
@@ -440,6 +442,7 @@ func (c *Container) NamedVolumes() []*ContainerNamedVolume {
|
||||
newVol.Name = vol.Name
|
||||
newVol.Dest = vol.Dest
|
||||
newVol.Options = vol.Options
|
||||
newVol.SubPath = vol.SubPath
|
||||
volumes = append(volumes, newVol)
|
||||
}
|
||||
|
||||
|
||||
@@ -157,6 +157,10 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if len(namedVol.SubPath) > 0 {
|
||||
mountPoint = filepath.Join(mountPoint, namedVol.SubPath)
|
||||
}
|
||||
|
||||
overlayFlag := false
|
||||
upperDir := ""
|
||||
workDir := ""
|
||||
|
||||
@@ -1440,6 +1440,7 @@ func WithNamedVolumes(volumes []*ContainerNamedVolume) CtrCreateOption {
|
||||
Dest: vol.Dest,
|
||||
Options: mountOpts,
|
||||
IsAnonymous: vol.IsAnonymous,
|
||||
SubPath: vol.SubPath,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user