libnetwork: ipvlan: cleanup parseNetworkGenericOptions

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

View file

@ -215,24 +215,21 @@ func parseNetworkOptions(id string, option options.Generic) (*configuration, err
// parseNetworkGenericOptions parse 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.