Skip to content

Commit 48a397e

Browse files
committed
Preserve volume spec items
Otherwise things like read_only, sub_path, etc are dropped from the final spec.
1 parent 4b9e59c commit 48a397e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

kubeluigi/k8s.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,11 @@ def get_container_with_volume_mounts(container):
9292
"""
9393
volumes_spec = container["volume_mounts"]
9494
mount_volumes = []
95+
keys_to_omit = {"host_path"}
9596
for volume in volumes_spec:
96-
mount_path = volume["mountPath"]
97-
name = volume["name"]
98-
mount_volumes.append(V1VolumeMount(mount_path=mount_path, name=name))
97+
# we need things like read_only, sub_path, etc:
98+
volume_std_spec = {k: v for k, v in volume.items() if k not in keys_to_omit}
99+
mount_volumes.append(V1VolumeMount(**volume_std_spec))
99100
container["volume_mounts"] = mount_volumes
100101
return container
101102

test/kubernetes_helpers_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def test_pod_spec_from_dict():
5656
"imagePullPolicy": "Always",
5757
"env": [{"name": "my_env", "value": "env"}],
5858
"volume_mounts": [
59-
{"name": "Vname", "mountPath": "VmountPath", "host_path": "VhostPath"}
59+
{"name": "Vname", "mount_path": "VmountPath", "host_path": "VhostPath"}
6060
],
6161
}
6262
],
@@ -105,7 +105,7 @@ def test_pod_spec_with_volume_from_dict():
105105
"imagePullPolicy": "Always",
106106
"env": [{"name": "my_env", "value": "env"}],
107107
"volume_mounts": [
108-
{"name": "Vname", "mountPath": "VmountPath", "host_path": "VhostPath"}
108+
{"name": "Vname", "mount_path": "VmountPath", "host_path": "VhostPath"}
109109
],
110110
}
111111

0 commit comments

Comments
 (0)