2017-08-29 15:28:33 -04:00
|
|
|
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
|
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
|
|
|
|
}
|