-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mount): add mount related util functions
ref: longhorn/longhorn 7394 Signed-off-by: Jack Lin <[email protected]>
- Loading branch information
Showing
91 changed files
with
11,018 additions
and
33 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
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,14 @@ | ||
package utils | ||
|
||
import ( | ||
"k8s.io/mount-utils" | ||
) | ||
|
||
func IsMountPointReadOnly(mp mount.MountPoint) bool { | ||
for _, opt := range mp.Opts { | ||
if opt == "ro" { | ||
return true | ||
} | ||
} | ||
return false | ||
} |
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,41 @@ | ||
package utils | ||
|
||
import ( | ||
. "gopkg.in/check.v1" | ||
|
||
"github.com/longhorn/go-common-libs/test" | ||
"k8s.io/mount-utils" | ||
) | ||
|
||
func (s *TestSuite) TestIsMountPointReadOnly(c *C) { | ||
type testCase struct { | ||
input mount.MountPoint | ||
expected bool | ||
} | ||
testCases := map[string]testCase{ | ||
"readOnly": { | ||
input: mount.MountPoint{ | ||
Opts: []string{"ro"}, | ||
}, | ||
expected: true, | ||
}, | ||
"readWrite": { | ||
input: mount.MountPoint{ | ||
Opts: []string{"rw"}, | ||
}, | ||
expected: false, | ||
}, | ||
"empty": { | ||
input: mount.MountPoint{ | ||
Opts: []string{}, | ||
}, | ||
expected: false, | ||
}, | ||
} | ||
for testName, testCase := range testCases { | ||
c.Logf("testing utils.%v", testName) | ||
|
||
result := IsMountPointReadOnly(testCase.input) | ||
c.Assert(result, Equals, testCase.expected, Commentf(test.ErrResultFmt, testName)) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.