Skip to content

Commit

Permalink
util: refactor ProcessOptions into an internal function
Browse files Browse the repository at this point in the history
this is needed to add tests for the function without accessing the
file system.

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Mar 21, 2024
1 parent 49ab250 commit 50d764b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/util/mount_opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ type defaultMountOptions struct {
nodev bool
}

type getDefaultMountOptionsFn func(path string) (defaultMountOptions, error)

// ProcessOptions parses the options for a bind or tmpfs mount and ensures that
// they are sensible and follow convention. The isTmpfs variable controls
// whether extra, tmpfs-specific options will be allowed.
// The sourcePath variable, if not empty, contains a bind mount source.
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 (
foundWrite, foundSize, foundProp, foundMode, foundExec, foundSuid, foundDev, foundCopyUp, foundBind, foundZ, foundU, foundOverlay, foundIdmap, foundCopy, foundNoSwap, foundNoDereference bool
)
Expand Down

0 comments on commit 50d764b

Please sign in to comment.