mirror of
https://github.com/moby/moby.git
synced 2026-08-13 17:06:44 +00:00
Prior to this change, cnmallocator would call `ConfigGlobalScopeDefaultNetworks` right before initializing its IPAM drivers. This function was mutating some global state used during drivers init. This change just remove the global state, and adds an arg to ipams.Register and defaultipam.Register to pass the global pools by arguments instead. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
32 lines
986 B
Go
32 lines
986 B
Go
package ipams
|
|
|
|
import (
|
|
"github.com/docker/docker/libnetwork/ipamapi"
|
|
"github.com/docker/docker/libnetwork/ipams/defaultipam"
|
|
"github.com/docker/docker/libnetwork/ipams/null"
|
|
remoteIpam "github.com/docker/docker/libnetwork/ipams/remote"
|
|
"github.com/docker/docker/libnetwork/ipams/windowsipam"
|
|
"github.com/docker/docker/libnetwork/ipamutils"
|
|
"github.com/docker/docker/pkg/plugingetter"
|
|
)
|
|
|
|
// Register registers all the builtin drivers (ie. default, windowsipam, null
|
|
// and remote). If 'pg' is nil, the remote driver won't be registered.
|
|
func Register(r ipamapi.Registerer, pg plugingetter.PluginGetter, lAddrPools, gAddrPools []*ipamutils.NetworkToSplit) error {
|
|
if err := defaultipam.Register(r, lAddrPools, gAddrPools); err != nil {
|
|
return err
|
|
}
|
|
if err := windowsipam.Register(r); err != nil {
|
|
return err
|
|
}
|
|
if err := null.Register(r); err != nil {
|
|
return err
|
|
}
|
|
if pg != nil {
|
|
if err := remoteIpam.Register(r, pg); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|