2018-02-05 16:05:59 -05:00
|
|
|
package config // import "github.com/docker/docker/daemon/config"
|
2017-08-29 15:28:33 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/docker/api/types/swarm"
|
|
|
|
"github.com/docker/docker/daemon/cluster/convert"
|
2022-04-21 17:33:07 -04:00
|
|
|
"github.com/moby/swarmkit/v2/api/genericresource"
|
2017-08-29 15:28:33 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// ParseGenericResources parses and validates the specified string as a list of GenericResource
|
2017-10-29 15:30:31 -04:00
|
|
|
func ParseGenericResources(value []string) ([]swarm.GenericResource, error) {
|
|
|
|
if len(value) == 0 {
|
2017-08-29 15:28:33 -04:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
resources, err := genericresource.Parse(value)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
obj := convert.GenericResourcesFromGRPC(resources)
|
|
|
|
return obj, nil
|
|
|
|
}
|