|
@@ -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")
|