moby/libnetwork/ipams/builtin/builtin_unix.go
Jana Radhakrishnan 64a2d2a3a2 Fix ipams builtin package for darwin
Make ipams builtin package work for os x target as ipam
driver developers happen to be using os x as well.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
2016-04-15 14:48:49 -07:00

41 lines
902 B
Go

// +build linux freebsd solaris darwin
package builtin
import (
"fmt"
"github.com/docker/libnetwork/datastore"
"github.com/docker/libnetwork/ipam"
"github.com/docker/libnetwork/ipamapi"
"github.com/docker/libnetwork/ipamutils"
)
// Init registers the built-in ipam service with libnetwork
func Init(ic ipamapi.Callback, l, g interface{}) error {
var (
ok bool
localDs, globalDs datastore.DataStore
)
if l != nil {
if localDs, ok = l.(datastore.DataStore); !ok {
return fmt.Errorf("incorrect local datastore passed to built-in ipam init")
}
}
if g != nil {
if globalDs, ok = g.(datastore.DataStore); !ok {
return fmt.Errorf("incorrect global datastore passed to built-in ipam init")
}
}
ipamutils.InitNetworks()
a, err := ipam.NewAllocator(localDs, globalDs)
if err != nil {
return err
}
return ic.RegisterIpamDriver(ipamapi.DefaultIPAM, a)
}