diff --git a/daemon/config/config.go b/daemon/config/config.go index 74441d1a5c..d01d4a4fb4 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -502,7 +502,7 @@ func Validate(config *Config) error { } } - if _, err := opts.ParseGenericResources(config.NodeGenericResources); err != nil { + if _, err := ParseGenericResources(config.NodeGenericResources); err != nil { return err } diff --git a/daemon/config/opts.go b/daemon/config/opts.go new file mode 100644 index 0000000000..00f32e43bb --- /dev/null +++ b/daemon/config/opts.go @@ -0,0 +1,22 @@ +package config + +import ( + "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/daemon/cluster/convert" + "github.com/docker/swarmkit/api/genericresource" +) + +// ParseGenericResources parses and validates the specified string as a list of GenericResource +func ParseGenericResources(value string) ([]swarm.GenericResource, error) { + if value == "" { + return nil, nil + } + + resources, err := genericresource.Parse(value) + if err != nil { + return nil, err + } + + obj := convert.GenericResourcesFromGRPC(resources) + return obj, nil +} diff --git a/daemon/daemon.go b/daemon/daemon.go index 2ba0288e13..a11a1f8691 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -29,7 +29,6 @@ import ( "github.com/docker/docker/daemon/events" "github.com/docker/docker/daemon/exec" "github.com/docker/docker/daemon/logger" - "github.com/docker/docker/opts" "github.com/sirupsen/logrus" // register graph drivers _ "github.com/docker/docker/daemon/graphdriver/register" @@ -1053,7 +1052,7 @@ func (daemon *Daemon) setupInitLayer(initPath string) error { } func (daemon *Daemon) setGenericResources(conf *config.Config) error { - genericResources, err := opts.ParseGenericResources(conf.NodeGenericResources) + genericResources, err := config.ParseGenericResources(conf.NodeGenericResources) if err != nil { return err } diff --git a/opts/opts.go b/opts/opts.go index 300fb426ad..8d82f76792 100644 --- a/opts/opts.go +++ b/opts/opts.go @@ -7,10 +7,7 @@ import ( "regexp" "strings" - "github.com/docker/docker/api/types/swarm" - "github.com/docker/docker/daemon/cluster/convert" units "github.com/docker/go-units" - "github.com/docker/swarmkit/api/genericresource" ) var ( @@ -328,19 +325,3 @@ func (m *MemBytes) UnmarshalJSON(s []byte) error { *m = MemBytes(val) return err } - -// ParseGenericResources parses and validates the specified string as a list of GenericResource -func ParseGenericResources(value string) ([]swarm.GenericResource, error) { - if value == "" { - return nil, nil - } - - resources, err := genericresource.Parse(value) - if err != nil { - return nil, err - } - - obj := convert.GenericResourcesFromGRPC(resources) - - return obj, nil -}