diff --git a/libnetwork/drivers/ipvlan/ipvlan_network.go b/libnetwork/drivers/ipvlan/ipvlan_network.go index 8ac769641a..b3d5aaeb6e 100644 --- a/libnetwork/drivers/ipvlan/ipvlan_network.go +++ b/libnetwork/drivers/ipvlan/ipvlan_network.go @@ -223,8 +223,7 @@ func parseNetworkGenericOptions(data interface{}) (*configuration, error) { case *configuration: config = opt case map[string]string: - config = &configuration{} - err = config.fromOptions(opt) + return newConfigFromLabels(opt), nil case options.Generic: var opaqueConfig interface{} if opaqueConfig, err = options.GenerateFromModel(opt, config); err == nil { @@ -236,8 +235,9 @@ func parseNetworkGenericOptions(data interface{}) (*configuration, error) { return config, err } -// fromOptions binds the generic options to networkConfiguration to cache -func (config *configuration) fromOptions(labels map[string]string) error { +// newConfigFromLabels creates a new configuration from the given labels. +func newConfigFromLabels(labels map[string]string) *configuration { + config := &configuration{} for label, value := range labels { switch label { case parentOpt: @@ -251,7 +251,8 @@ func (config *configuration) fromOptions(labels map[string]string) error { config.IpvlanFlag = value } } - return nil + + return config } // processIPAM parses v4 and v6 IP information and binds it to the network configuration