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

Move validateOpts() to local_unix.go as it is not used on Windows

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-12-22 03:02:28 +01:00
parent 11b88be247
commit 0d6dd91e13
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
3 changed files with 18 additions and 22 deletions

View file

@ -344,23 +344,6 @@ func (v *localVolume) unmount() error {
return nil return nil
} }
func validateOpts(opts map[string]string) error {
if len(opts) == 0 {
return nil
}
for opt := range opts {
if _, ok := validOpts[opt]; !ok {
return errdefs.InvalidParameter(errors.Errorf("invalid option: %q", opt))
}
}
for opt := range mandatoryOpts {
if _, ok := opts[opt]; !ok {
return errdefs.InvalidParameter(errors.Errorf("missing required option: %q", opt))
}
}
return nil
}
func (v *localVolume) Status() map[string]interface{} { func (v *localVolume) Status() map[string]interface{} {
return nil return nil
} }

View file

@ -14,6 +14,7 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/mount" "github.com/docker/docker/pkg/mount"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -74,6 +75,23 @@ func setOpts(v *localVolume, opts map[string]string) error {
return nil return nil
} }
func validateOpts(opts map[string]string) error {
if len(opts) == 0 {
return nil
}
for opt := range opts {
if _, ok := validOpts[opt]; !ok {
return errdefs.InvalidParameter(errors.Errorf("invalid option: %q", opt))
}
}
for opt := range mandatoryOpts {
if _, ok := opts[opt]; !ok {
return errdefs.InvalidParameter(errors.Errorf("missing required option: %q", opt))
}
}
return nil
}
func (v *localVolume) mount() error { func (v *localVolume) mount() error {
if v.opts.MountDevice == "" { if v.opts.MountDevice == "" {
return fmt.Errorf("missing device in volume options") return fmt.Errorf("missing device in volume options")

View file

@ -16,11 +16,6 @@ import (
type optsConfig struct{} type optsConfig struct{}
var (
validOpts map[string]struct{}
mandatoryOpts map[string]struct{}
)
// scopedPath verifies that the path where the volume is located // scopedPath verifies that the path where the volume is located
// is under Docker's root and the valid local paths. // is under Docker's root and the valid local paths.
func (r *Root) scopedPath(realPath string) bool { func (r *Root) scopedPath(realPath string) bool {