diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-02-23 12:56:10 +0100 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2022-02-23 13:01:40 +0100 |
commit | ed73040b35c220164a6a7271ab4a0b88f288da5e (patch) | |
tree | 1b2e619faab87be917bf9afaec895c28413b81dd /pkg/specgen/generate/kube/kube_test.go | |
parent | 8b2432422fc188e15130c888a05e41fd881b8ca4 (diff) | |
download | podman-ed73040b35c220164a6a7271ab4a0b88f288da5e.tar.gz podman-ed73040b35c220164a6a7271ab4a0b88f288da5e.tar.bz2 podman-ed73040b35c220164a6a7271ab4a0b88f288da5e.zip |
kube: honor mount propagation mode
convert the propagation mode specified for the mount to the expected
Linux mount option.
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'pkg/specgen/generate/kube/kube_test.go')
-rw-r--r-- | pkg/specgen/generate/kube/kube_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/pkg/specgen/generate/kube/kube_test.go b/pkg/specgen/generate/kube/kube_test.go new file mode 100644 index 000000000..62793ebb6 --- /dev/null +++ b/pkg/specgen/generate/kube/kube_test.go @@ -0,0 +1,42 @@ +package kube + +import ( + "testing" + + "github.com/stretchr/testify/assert" + v1 "k8s.io/api/core/v1" + //"github.com/stretchr/testify/require" +) + +func testPropagation(t *testing.T, propagation v1.MountPropagationMode, expected string) { + dest, options, err := parseMountPath("/to", false, &propagation) + assert.NoError(t, err) + assert.Equal(t, dest, "/to") + assert.Contains(t, options, expected) +} + +func TestParseMountPathPropagation(t *testing.T) { + testPropagation(t, v1.MountPropagationNone, "private") + testPropagation(t, v1.MountPropagationHostToContainer, "rslave") + testPropagation(t, v1.MountPropagationBidirectional, "rshared") + + prop := v1.MountPropagationMode("SpaceWave") + _, _, err := parseMountPath("/to", false, &prop) + assert.Error(t, err) + + _, options, err := parseMountPath("/to", false, nil) + assert.NoError(t, err) + assert.NotContains(t, options, "private") + assert.NotContains(t, options, "rslave") + assert.NotContains(t, options, "rshared") +} + +func TestParseMountPathRO(t *testing.T) { + _, options, err := parseMountPath("/to", true, nil) + assert.NoError(t, err) + assert.Contains(t, options, "ro") + + _, options, err = parseMountPath("/to", false, nil) + assert.NoError(t, err) + assert.NotContains(t, options, "ro") +} |