1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Use a map[string]struct{} for validOpts

For consistency with `mandatoryOpts`, and because it is a
tiny-tiny bit more efficient.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-12-22 02:23:17 +01:00
parent d5b271c155
commit 342f7a357a
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 6 additions and 6 deletions

View file

@ -357,7 +357,7 @@ func validateOpts(opts map[string]string) error {
return nil
}
for opt := range opts {
if !validOpts[opt] {
if _, ok := validOpts[opt]; !ok {
return validationError(fmt.Sprintf("invalid option key: %q", opt))
}
}

View file

@ -22,10 +22,10 @@ import (
var (
oldVfsDir = filepath.Join("vfs", "dir")
validOpts = map[string]bool{
"type": true, // specify the filesystem type for mount, e.g. nfs
"o": true, // generic mount options
"device": true, // device to mount from
validOpts = map[string]struct{}{
"type": {}, // specify the filesystem type for mount, e.g. nfs
"o": {}, // generic mount options
"device": {}, // device to mount from
}
mandatoryOpts = map[string]struct{}{
"device": {},

View file

@ -15,7 +15,7 @@ import (
type optsConfig struct{}
var (
validOpts map[string]bool
validOpts map[string]struct{}
mandatoryOpts map[string]struct{}
)