Merge pull request #16803 from cdoern/subpath

add support for subpath in play kube for named volumes
This commit is contained in:
OpenShift Merge Robot
2022-12-12 12:37:59 -05:00
committed by GitHub
7 changed files with 69 additions and 0 deletions

View File

@@ -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)
}

View File

@@ -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 := ""

View File

@@ -1440,6 +1440,7 @@ func WithNamedVolumes(volumes []*ContainerNamedVolume) CtrCreateOption {
Dest: vol.Dest,
Options: mountOpts,
IsAnonymous: vol.IsAnonymous,
SubPath: vol.SubPath,
})
}