diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-05-23 10:06:07 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-23 10:06:07 -0400 |
commit | e11d8d4650a4ec50064aab416bebb364ac8ac4bf (patch) | |
tree | f97be30f89dfad417f0a8ac8430389159ea102b0 /pkg/specgen/generate/kube/volume.go | |
parent | 0d2209eb6a8ab8276795db2b3b7e5708754c4054 (diff) | |
parent | 4960a17a56523c0c022992e841262f89312db694 (diff) | |
download | podman-e11d8d4650a4ec50064aab416bebb364ac8ac4bf.tar.gz podman-e11d8d4650a4ec50064aab416bebb364ac8ac4bf.tar.bz2 podman-e11d8d4650a4ec50064aab416bebb364ac8ac4bf.zip |
Merge pull request #14266 from tupyy/add-blockdevice-play-kube
Expose block and character devices with play kube
Diffstat (limited to 'pkg/specgen/generate/kube/volume.go')
-rw-r--r-- | pkg/specgen/generate/kube/volume.go | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/pkg/specgen/generate/kube/volume.go b/pkg/specgen/generate/kube/volume.go index 27881e77a..1d6d49b9d 100644 --- a/pkg/specgen/generate/kube/volume.go +++ b/pkg/specgen/generate/kube/volume.go @@ -22,8 +22,10 @@ type KubeVolumeType int const ( KubeVolumeTypeBindMount KubeVolumeType = iota - KubeVolumeTypeNamed KubeVolumeType = iota - KubeVolumeTypeConfigMap KubeVolumeType = iota + KubeVolumeTypeNamed + KubeVolumeTypeConfigMap + KubeVolumeTypeBlockDevice + KubeVolumeTypeCharDevice ) //nolint:revive @@ -78,7 +80,30 @@ func VolumeFromHostPath(hostPath *v1.HostPathVolumeSource) (*KubeVolume, error) if st.Mode()&os.ModeSocket != os.ModeSocket { return nil, errors.Errorf("checking HostPathSocket: path %s is not a socket", hostPath.Path) } - + case v1.HostPathBlockDev: + dev, err := os.Stat(hostPath.Path) + if err != nil { + return nil, errors.Wrap(err, "error checking HostPathBlockDevice") + } + if dev.Mode()&os.ModeCharDevice == os.ModeCharDevice { + return nil, errors.Errorf("checking HostPathDevice: path %s is not a block device", hostPath.Path) + } + return &KubeVolume{ + Type: KubeVolumeTypeBlockDevice, + Source: hostPath.Path, + }, nil + case v1.HostPathCharDev: + dev, err := os.Stat(hostPath.Path) + if err != nil { + return nil, errors.Wrap(err, "error checking HostPathCharDevice") + } + if dev.Mode()&os.ModeCharDevice != os.ModeCharDevice { + return nil, errors.Errorf("checking HostPathCharDevice: path %s is not a character device", hostPath.Path) + } + return &KubeVolume{ + Type: KubeVolumeTypeCharDevice, + Source: hostPath.Path, + }, nil case v1.HostPathDirectory: case v1.HostPathFile: case v1.HostPathUnset: |