mirror of
https://github.com/containers/podman.git
synced 2025-06-22 09:58:10 +08:00
util: refactor ProcessOptions into an internal function
this is needed to add tests for the function without accessing the file system. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -22,11 +22,17 @@ type defaultMountOptions struct {
|
|||||||
nodev bool
|
nodev bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type getDefaultMountOptionsFn func(path string) (defaultMountOptions, error)
|
||||||
|
|
||||||
// ProcessOptions parses the options for a bind or tmpfs mount and ensures that
|
// ProcessOptions parses the options for a bind or tmpfs mount and ensures that
|
||||||
// they are sensible and follow convention. The isTmpfs variable controls
|
// they are sensible and follow convention. The isTmpfs variable controls
|
||||||
// whether extra, tmpfs-specific options will be allowed.
|
// whether extra, tmpfs-specific options will be allowed.
|
||||||
// The sourcePath variable, if not empty, contains a bind mount source.
|
// The sourcePath variable, if not empty, contains a bind mount source.
|
||||||
func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string, error) {
|
func ProcessOptions(options []string, isTmpfs bool, sourcePath string) ([]string, error) {
|
||||||
|
return processOptionsInternal(options, isTmpfs, sourcePath, getDefaultMountOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
func processOptionsInternal(options []string, isTmpfs bool, sourcePath string, getDefaultMountOptions getDefaultMountOptionsFn) ([]string, error) {
|
||||||
var (
|
var (
|
||||||
foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU, foundOverlay, foundIdmap, foundCopy, foundNoSwap, foundNoDereference bool
|
foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU, foundOverlay, foundIdmap, foundCopy, foundNoSwap, foundNoDereference bool
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user