mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Add kube play support for image volume source
Signed-off-by: Mario Loriedo <mario.loriedo@gmail.com>
This commit is contained in:
@ -567,6 +567,14 @@ func ToSpecGen(ctx context.Context, opts *CtrSpecGenOptions) (*specgen.SpecGener
|
||||
Source: define.TypeTmpfs,
|
||||
}
|
||||
s.Mounts = append(s.Mounts, memVolume)
|
||||
case KubeVolumeTypeImage:
|
||||
imageVolume := specgen.ImageVolume{
|
||||
Destination: volume.MountPath,
|
||||
ReadWrite: false,
|
||||
Source: volumeSource.Source,
|
||||
SubPath: "",
|
||||
}
|
||||
s.ImageVolumes = append(s.ImageVolumes, &imageVolume)
|
||||
default:
|
||||
return nil, errors.New("unsupported volume source type")
|
||||
}
|
||||
|
@ -37,13 +37,14 @@ const (
|
||||
KubeVolumeTypeSecret
|
||||
KubeVolumeTypeEmptyDir
|
||||
KubeVolumeTypeEmptyDirTmpfs
|
||||
KubeVolumeTypeImage
|
||||
)
|
||||
|
||||
//nolint:revive
|
||||
type KubeVolume struct {
|
||||
// Type of volume to create
|
||||
Type KubeVolumeType
|
||||
// Path for bind mount or volume name for named volume
|
||||
// Path for bind mount, volume name for named volume or image name for image volume
|
||||
Source string
|
||||
// Items to add to a named volume created where the key is the file name and the value is the data
|
||||
// This is only used when there are volumes in the yaml that refer to a configmap
|
||||
@ -56,6 +57,8 @@ type KubeVolume struct {
|
||||
// DefaultMode sets the permissions on files created for the volume
|
||||
// This is optional and defaults to 0644
|
||||
DefaultMode int32
|
||||
// Used for volumes of type Image. Ignored for other volumes types.
|
||||
ImagePullPolicy v1.PullPolicy
|
||||
}
|
||||
|
||||
// Create a KubeVolume from an HostPathVolumeSource
|
||||
@ -279,6 +282,14 @@ func VolumeFromEmptyDir(emptyDirVolumeSource *v1.EmptyDirVolumeSource, name stri
|
||||
}
|
||||
}
|
||||
|
||||
func VolumeFromImage(imageVolumeSource *v1.ImageVolumeSource, name string) (*KubeVolume, error) {
|
||||
return &KubeVolume{
|
||||
Type: KubeVolumeTypeImage,
|
||||
Source: imageVolumeSource.Reference,
|
||||
ImagePullPolicy: imageVolumeSource.PullPolicy,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Create a KubeVolume from one of the supported VolumeSource
|
||||
func VolumeFromSource(volumeSource v1.VolumeSource, configMaps []v1.ConfigMap, secretsManager *secrets.SecretsManager, volName, mountLabel string) (*KubeVolume, error) {
|
||||
switch {
|
||||
@ -292,6 +303,8 @@ func VolumeFromSource(volumeSource v1.VolumeSource, configMaps []v1.ConfigMap, s
|
||||
return VolumeFromSecret(volumeSource.Secret, secretsManager)
|
||||
case volumeSource.EmptyDir != nil:
|
||||
return VolumeFromEmptyDir(volumeSource.EmptyDir, volName)
|
||||
case volumeSource.Image != nil:
|
||||
return VolumeFromImage(volumeSource.Image, volName)
|
||||
default:
|
||||
return nil, errors.New("HostPath, ConfigMap, EmptyDir, Secret, and PersistentVolumeClaim are currently the only supported VolumeSource")
|
||||
}
|
||||
|
Reference in New Issue
Block a user