From 8b189c0a0627e04578fe6591e61af850182b78be Mon Sep 17 00:00:00 2001 From: Mikhail Khachayants Date: Thu, 6 Oct 2022 10:05:19 +0300 Subject: Create full path to a directory when DirectoryOrCreate is used with play kube Signed-off-by: Mikhail Khachayants --- pkg/specgen/generate/kube/volume.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'pkg') diff --git a/pkg/specgen/generate/kube/volume.go b/pkg/specgen/generate/kube/volume.go index 2d8085020..beb460d68 100644 --- a/pkg/specgen/generate/kube/volume.go +++ b/pkg/specgen/generate/kube/volume.go @@ -56,10 +56,8 @@ func VolumeFromHostPath(hostPath *v1.HostPathVolumeSource) (*KubeVolume, error) if hostPath.Type != nil { switch *hostPath.Type { case v1.HostPathDirectoryOrCreate: - if _, err := os.Stat(hostPath.Path); os.IsNotExist(err) { - if err := os.Mkdir(hostPath.Path, kubeDirectoryPermission); err != nil { - return nil, err - } + if err := os.MkdirAll(hostPath.Path, kubeDirectoryPermission); err != nil { + return nil, err } // Label a newly created volume if err := libpod.LabelVolumePath(hostPath.Path); err != nil { -- cgit v1.2.3-54-g00ecf