Skip to content

Commit

Permalink
fix add directoryorcreate to volumes (#174)
Browse files Browse the repository at this point in the history
Signed-off-by: Jefiya M J <[email protected]>
  • Loading branch information
Jefiya-MJ authored Jul 1, 2024
1 parent 251b49c commit 0e358d9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/k8s/object/builders/common/volume/volume.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
(c) Copyright IBM Corp. 2024
(c) Copyright Instana Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package volume

import (
Expand All @@ -15,6 +32,7 @@ type hostVolumeWithMountParams struct {
name string
path string
*corev1.MountPropagationMode
hostPathType *corev1.HostPathType
}

type VolumeWithMount struct {
Expand All @@ -29,6 +47,7 @@ func hostVolumeWithMount(params *hostVolumeWithMountParams) VolumeWithMount {
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: params.path,
Type: params.hostPathType,
},
},
},
Expand Down Expand Up @@ -93,6 +112,7 @@ func (v *volumeBuilder) varRunKuboVolume() optional.Optional[VolumeWithMount] {
name: "var-run-kubo",
path: "/var/vcap/sys/run/docker",
MountPropagationMode: pointer.To(corev1.MountPropagationHostToContainer),
hostPathType: pointer.To(corev1.HostPathDirectoryOrCreate),
},
)
}
Expand All @@ -104,6 +124,7 @@ func (v *volumeBuilder) varRunContainerdVolume() optional.Optional[VolumeWithMou
name: "var-run-containerd",
path: "/var/vcap/sys/run/containerd",
MountPropagationMode: pointer.To(corev1.MountPropagationHostToContainer),
hostPathType: pointer.To(corev1.HostPathDirectoryOrCreate),
},
)
}
Expand All @@ -115,6 +136,7 @@ func (v *volumeBuilder) varContainerdConfigVolume() optional.Optional[VolumeWith
name: "var-containerd-config",
path: "/var/vcap/jobs/containerd/config",
MountPropagationMode: pointer.To(corev1.MountPropagationHostToContainer),
hostPathType: pointer.To(corev1.HostPathDirectoryOrCreate),
},
)
}
Expand Down Expand Up @@ -155,6 +177,7 @@ func (v *volumeBuilder) varDataVolume() optional.Optional[VolumeWithMount] {
name: "var-data",
path: "/var/data",
MountPropagationMode: pointer.To(corev1.MountPropagationHostToContainer),
hostPathType: pointer.To(corev1.HostPathDirectoryOrCreate),
},
)
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/k8s/object/builders/common/volume/volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func testHostLiteralVolume(
VolumeSource: corev1.VolumeSource{
HostPath: &corev1.HostPathVolumeSource{
Path: expected.path,
Type: expected.hostPathType,
},
},
},
Expand Down Expand Up @@ -134,6 +135,7 @@ func TestVarRunKuboVolume(t *testing.T) {
name: "var-run-kubo",
path: "/var/vcap/sys/run/docker",
MountPropagationMode: pointer.To(corev1.MountPropagationHostToContainer),
hostPathType: pointer.To(corev1.HostPathDirectoryOrCreate),
},
VarRunKuboVolume,
)
Expand All @@ -146,6 +148,7 @@ func TestVarRunContainerdVolume(t *testing.T) {
name: "var-run-containerd",
path: "/var/vcap/sys/run/containerd",
MountPropagationMode: pointer.To(corev1.MountPropagationHostToContainer),
hostPathType: pointer.To(corev1.HostPathDirectoryOrCreate),
},
VarRunContainerdVolume,
)
Expand All @@ -158,6 +161,7 @@ func TestVarContainerdConfigVolume(t *testing.T) {
name: "var-containerd-config",
path: "/var/vcap/jobs/containerd/config",
MountPropagationMode: pointer.To(corev1.MountPropagationHostToContainer),
hostPathType: pointer.To(corev1.HostPathDirectoryOrCreate),
},
VarContainerdConfigVolume,
)
Expand Down Expand Up @@ -206,6 +210,7 @@ func TestVarDataVolume(t *testing.T) {
name: "var-data",
path: "/var/data",
MountPropagationMode: pointer.To(corev1.MountPropagationHostToContainer),
hostPathType: pointer.To(corev1.HostPathDirectoryOrCreate),
},
VarDataVolume,
)
Expand Down

0 comments on commit 0e358d9

Please sign in to comment.