diff options
author | Peter Hunt <pehunt@redhat.com> | 2019-04-14 16:16:36 -0400 |
---|---|---|
committer | Peter Hunt <pehunt@redhat.com> | 2019-04-15 09:27:36 -0400 |
commit | 2f804ea9a28d781946313c7f3b6a6c97919f9839 (patch) | |
tree | 2f9df15d1c8ecd90daf56ae649d9fa163a899c38 /cmd | |
parent | 167ce59416f6e03f4477269e33e9e5cf5b700a86 (diff) | |
download | podman-2f804ea9a28d781946313c7f3b6a6c97919f9839.tar.gz podman-2f804ea9a28d781946313c7f3b6a6c97919f9839.tar.bz2 podman-2f804ea9a28d781946313c7f3b6a6c97919f9839.zip |
Add File mounts to play kube
Both File and FileOrCreate options are supported.
Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/play_kube.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd/podman/play_kube.go b/cmd/podman/play_kube.go index cbe961279..982e12d44 100644 --- a/cmd/podman/play_kube.go +++ b/cmd/podman/play_kube.go @@ -28,6 +28,8 @@ import ( const ( // https://kubernetes.io/docs/concepts/storage/volumes/#hostpath createDirectoryPermission = 0755 + // https://kubernetes.io/docs/concepts/storage/volumes/#hostpath + createFilePermission = 0644 ) var ( @@ -169,7 +171,23 @@ func playKubeYAMLCmd(c *cliconfig.KubePlayValues) error { return errors.Wrapf(err, "Error giving %s a label", hostPath.Path) } break + case v1.HostPathFileOrCreate: + if _, err := os.Stat(hostPath.Path); os.IsNotExist(err) { + f, err := os.OpenFile(hostPath.Path, os.O_RDONLY|os.O_CREATE, createFilePermission) + if err != nil { + return errors.Errorf("Error creating HostPath %s at %s", volume.Name, hostPath.Path) + } + if err := f.Close(); err != nil { + logrus.Warnf("Error in closing newly created HostPath file: %v", err) + } + } + // unconditionally label a newly created volume as private + if err := libpod.LabelVolumePath(hostPath.Path, false); err != nil { + return errors.Wrapf(err, "Error giving %s a label", hostPath.Path) + } + break case v1.HostPathDirectory: + case v1.HostPathFile: case v1.HostPathUnset: // do nothing here because we will verify the path exists in validateVolumeHostDir break |