Browse Source

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 6 years ago
parent
commit
0d6dd91e13
3 changed files with 18 additions and 22 deletions
  1. 0 17
      volume/local/local.go
  2. 18 0
      volume/local/local_unix.go
  3. 0 5
      volume/local/local_windows.go

+ 0 - 17
volume/local/local.go

@@ -344,23 +344,6 @@ func (v *localVolume) unmount() error {
 	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{} {
 	return nil
 }

+ 18 - 0
volume/local/local_unix.go

@@ -14,6 +14,7 @@ import (
 	"syscall"
 	"time"
 
+	"github.com/docker/docker/errdefs"
 	"github.com/docker/docker/pkg/mount"
 	"github.com/pkg/errors"
 )
@@ -74,6 +75,23 @@ func setOpts(v *localVolume, opts map[string]string) error {
 	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 {
 	if v.opts.MountDevice == "" {
 		return fmt.Errorf("missing device in volume options")

+ 0 - 5
volume/local/local_windows.go

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