libnetwork: macvlan: cleanup parseNetworkGenericOptions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-07-01 11:21:42 +02:00
parent 1992190162
commit dddb4d25d2
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -195,25 +195,21 @@ func parseNetworkOptions(id string, option options.Generic) (*configuration, err
// parseNetworkGenericOptions parses generic driver docker network options
func parseNetworkGenericOptions(data interface{}) (*configuration, error) {
var (
err error
config *configuration
)
switch opt := data.(type) {
case *configuration:
config = opt
return opt, nil
case map[string]string:
return newConfigFromLabels(opt), nil
case options.Generic:
var opaqueConfig interface{}
if opaqueConfig, err = options.GenerateFromModel(opt, config); err == nil {
config = opaqueConfig.(*configuration)
var config *configuration
opaqueConfig, err := options.GenerateFromModel(opt, config)
if err != nil {
return nil, err
}
return opaqueConfig.(*configuration), nil
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.