-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert the propagation mode specified for the mount to the expected Linux mount option. Signed-off-by: Giuseppe Scrivano <[email protected]>
- Loading branch information
Showing
2 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} |