libnetwork: ipvlan: make configuration.fromOptions a constructor
This was effectively a constructor, but through some indirection; make it a regular function, which is a bit more idiomatic. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
4e39cdd9bb
commit
1a1a885423
1 changed files with 6 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue