opts.go 601 B

12345678910111213141516171819202122
  1. package config // import "github.com/docker/docker/daemon/config"
  2. import (
  3. "github.com/docker/docker/api/types/swarm"
  4. "github.com/docker/docker/daemon/cluster/convert"
  5. "github.com/moby/swarmkit/v2/api/genericresource"
  6. )
  7. // ParseGenericResources parses and validates the specified string as a list of GenericResource
  8. func ParseGenericResources(value []string) ([]swarm.GenericResource, error) {
  9. if len(value) == 0 {
  10. return nil, nil
  11. }
  12. resources, err := genericresource.Parse(value)
  13. if err != nil {
  14. return nil, err
  15. }
  16. obj := convert.GenericResourcesFromGRPC(resources)
  17. return obj, nil
  18. }