2015-02-20 01:37:53 +00:00
|
|
|
package libnetwork
|
|
|
|
|
2015-02-20 06:21:05 +00:00
|
|
|
import (
|
2023-07-04 17:30:54 +00:00
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/docker/docker/libnetwork/driverapi"
|
2021-04-06 00:24:47 +00:00
|
|
|
"github.com/docker/docker/libnetwork/drivers/bridge"
|
|
|
|
"github.com/docker/docker/libnetwork/drivers/host"
|
|
|
|
"github.com/docker/docker/libnetwork/drivers/ipvlan"
|
|
|
|
"github.com/docker/docker/libnetwork/drivers/macvlan"
|
|
|
|
"github.com/docker/docker/libnetwork/drivers/null"
|
|
|
|
"github.com/docker/docker/libnetwork/drivers/overlay"
|
2015-02-20 06:21:05 +00:00
|
|
|
)
|
2015-02-20 01:37:53 +00:00
|
|
|
|
2023-07-04 17:30:54 +00:00
|
|
|
func registerNetworkDrivers(r driverapi.Registerer, driverConfig func(string) map[string]interface{}) error {
|
2023-07-04 17:43:16 +00:00
|
|
|
noConfig := func(fn func(driverapi.Registerer) error) func(driverapi.Registerer, map[string]interface{}) error {
|
|
|
|
return func(r driverapi.Registerer, _ map[string]interface{}) error { return fn(r) }
|
|
|
|
}
|
|
|
|
|
2023-07-04 17:30:54 +00:00
|
|
|
for _, nr := range []struct {
|
|
|
|
ntype string
|
|
|
|
register func(driverapi.Registerer, map[string]interface{}) error
|
|
|
|
}{
|
|
|
|
{ntype: bridge.NetworkType, register: bridge.Register},
|
2023-07-04 17:43:16 +00:00
|
|
|
{ntype: host.NetworkType, register: noConfig(host.Register)},
|
2023-07-04 17:30:54 +00:00
|
|
|
{ntype: ipvlan.NetworkType, register: ipvlan.Register},
|
|
|
|
{ntype: macvlan.NetworkType, register: macvlan.Register},
|
2023-07-04 17:43:16 +00:00
|
|
|
{ntype: null.NetworkType, register: noConfig(null.Register)},
|
2023-07-04 17:30:54 +00:00
|
|
|
{ntype: overlay.NetworkType, register: overlay.Register},
|
|
|
|
} {
|
|
|
|
if err := nr.register(r, driverConfig(nr.ntype)); err != nil {
|
|
|
|
return fmt.Errorf("failed to register %q driver: %w", nr.ntype, err)
|
|
|
|
}
|
2015-02-20 06:21:05 +00:00
|
|
|
}
|
2023-07-04 17:30:54 +00:00
|
|
|
|
|
|
|
return nil
|
2015-02-20 17:12:29 +00:00
|
|
|
}
|