mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
libnetwork: macvlan: cleanup parseNetworkGenericOptions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
1992190162
commit
dddb4d25d2
1 changed files with 7 additions and 11 deletions
|
@ -195,25 +195,21 @@ func parseNetworkOptions(id string, option options.Generic) (*configuration, err
|
||||||
|
|
||||||
// parseNetworkGenericOptions parses generic driver docker network options
|
// parseNetworkGenericOptions parses generic driver docker network options
|
||||||
func parseNetworkGenericOptions(data interface{}) (*configuration, error) {
|
func parseNetworkGenericOptions(data interface{}) (*configuration, error) {
|
||||||
var (
|
|
||||||
err error
|
|
||||||
config *configuration
|
|
||||||
)
|
|
||||||
switch opt := data.(type) {
|
switch opt := data.(type) {
|
||||||
case *configuration:
|
case *configuration:
|
||||||
config = opt
|
return opt, nil
|
||||||
case map[string]string:
|
case map[string]string:
|
||||||
return newConfigFromLabels(opt), nil
|
return newConfigFromLabels(opt), nil
|
||||||
case options.Generic:
|
case options.Generic:
|
||||||
var opaqueConfig interface{}
|
var config *configuration
|
||||||
if opaqueConfig, err = options.GenerateFromModel(opt, config); err == nil {
|
opaqueConfig, err := options.GenerateFromModel(opt, config)
|
||||||
config = opaqueConfig.(*configuration)
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
}
|
}
|
||||||
|
return opaqueConfig.(*configuration), nil
|
||||||
default:
|
default:
|
||||||
err = types.BadRequestErrorf("unrecognized network configuration format: %v", opt)
|
return nil, types.BadRequestErrorf("unrecognized network configuration format: %v", opt)
|
||||||
}
|
}
|
||||||
|
|
||||||
return config, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// newConfigFromLabels creates a new configuration from the given labels.
|
// newConfigFromLabels creates a new configuration from the given labels.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue