libnet/drivers: stop passing config to drivers...

...which ignore the config argument. Notably, none of the network
drivers referenced by Swarmkit use config, which is good as Swarmkit
unconditionally passes nil for the config when registering drivers.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider 2023-07-04 13:43:16 -04:00
parent 1980deffae
commit d519bde5da
10 changed files with 21 additions and 17 deletions

View file

@ -15,11 +15,11 @@ type driver struct{}
//
// Deprecated: use [Register].
func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
return Register(dc, nil)
return Register(dc)
}
// Register registers a new instance of the bridge manager driver with r.
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
func Register(r driverapi.Registerer) error {
return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{
DataScope: datastore.LocalScope,
ConnectivityScope: datastore.LocalScope,

View file

@ -20,10 +20,10 @@ type driver struct {
//
// Deprecated: use [Register].
func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
return Register(dc, nil)
return Register(dc)
}
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
func Register(r driverapi.Registerer) error {
return r.RegisterDriver(NetworkType, &driver{}, driverapi.Capability{
DataScope: datastore.LocalScope,
ConnectivityScope: datastore.LocalScope,

View file

@ -15,11 +15,11 @@ type driver struct{}
//
// Deprecated: use [Register].
func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
return Register(dc, nil)
return Register(dc)
}
// Register registers a new instance of the ipvlan manager driver.
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
func Register(r driverapi.Registerer) error {
return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{
DataScope: datastore.LocalScope,
ConnectivityScope: datastore.GlobalScope,

View file

@ -15,11 +15,11 @@ type driver struct{}
//
// Deprecated: use [Register].
func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
return Register(dc, nil)
return Register(dc)
}
// Register registers a new instance of the macvlan manager driver.
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
func Register(r driverapi.Registerer) error {
return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{
DataScope: datastore.LocalScope,
ConnectivityScope: datastore.GlobalScope,

View file

@ -17,7 +17,7 @@ type driver struct {
}
// Register registers a new instance of the null driver.
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
func Register(r driverapi.Registerer) error {
return r.RegisterDriver(NetworkType, &driver{}, driverapi.Capability{
DataScope: datastore.LocalScope,
})

View file

@ -50,11 +50,11 @@ type network struct {
//
// Deprecated: use [Register].
func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
return Register(dc, nil)
return Register(dc)
}
// Register registers a new instance of the overlay driver.
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
func Register(r driverapi.Registerer) error {
return r.RegisterDriver(networkType, newDriver(), driverapi.Capability{
DataScope: datastore.GlobalScope,
ConnectivityScope: datastore.GlobalScope,

View file

@ -26,7 +26,7 @@ type driver struct {
}
// Register registers a new instance of the overlay driver.
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
func Register(r driverapi.Registerer) error {
d := &driver{
networks: networkTable{},
}

View file

@ -5,5 +5,5 @@ import (
)
func registerNetworkDrivers(r driverapi.Registerer, driverConfig func(string) map[string]interface{}) error {
return null.Register(r, driverConfig(null.NetworkType))
return null.Register(r)
}

View file

@ -13,15 +13,19 @@ import (
)
func registerNetworkDrivers(r driverapi.Registerer, driverConfig func(string) map[string]interface{}) error {
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) }
}
for _, nr := range []struct {
ntype string
register func(driverapi.Registerer, map[string]interface{}) error
}{
{ntype: bridge.NetworkType, register: bridge.Register},
{ntype: host.NetworkType, register: host.Register},
{ntype: host.NetworkType, register: noConfig(host.Register)},
{ntype: ipvlan.NetworkType, register: ipvlan.Register},
{ntype: macvlan.NetworkType, register: macvlan.Register},
{ntype: null.NetworkType, register: null.Register},
{ntype: null.NetworkType, register: noConfig(null.Register)},
{ntype: overlay.NetworkType, register: overlay.Register},
} {
if err := nr.register(r, driverConfig(nr.ntype)); err != nil {

View file

@ -12,12 +12,12 @@ import (
func registerNetworkDrivers(r driverapi.Registerer, driverConfig func(string) map[string]interface{}) error {
for _, nr := range []struct {
ntype string
register func(driverapi.Registerer, map[string]interface{}) error
register func(driverapi.Registerer) error
}{
{ntype: null.NetworkType, register: null.Register},
{ntype: overlay.NetworkType, register: overlay.Register},
} {
if err := nr.register(r, driverConfig(nr.ntype)); err != nil {
if err := nr.register(r); err != nil {
return fmt.Errorf("failed to register %q driver: %w", nr.ntype, err)
}
}