mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Libnetwork passes a map[string]any to the bridge driver's Register function. This forces the daemon to convert its configuration into a map, and the driver to convert that map back into a struct. This is unnecessary complexity, and makes it harder to track down where and how bridge driver configuration fields are set. Refactor libnetwork to let the daemon register the bridge.Configuration directly through a new option `OptionBridgeConfig`. The bridge driver now takes a `Configuration` param that needs no special treatment. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
35 lines
1.1 KiB
Go
35 lines
1.1 KiB
Go
package libnetwork
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/moby/moby/v2/daemon/libnetwork/config"
|
|
"github.com/moby/moby/v2/daemon/libnetwork/datastore"
|
|
"github.com/moby/moby/v2/daemon/libnetwork/driverapi"
|
|
"github.com/moby/moby/v2/daemon/libnetwork/drivers/null"
|
|
"github.com/moby/moby/v2/daemon/libnetwork/drivers/windows"
|
|
"github.com/moby/moby/v2/daemon/libnetwork/drivers/windows/overlay"
|
|
"github.com/moby/moby/v2/daemon/libnetwork/drvregistry"
|
|
)
|
|
|
|
func registerNetworkDrivers(r driverapi.Registerer, _ *config.Config, store *datastore.Store, _ *drvregistry.PortMappers) error {
|
|
for _, nr := range []struct {
|
|
ntype string
|
|
register func(driverapi.Registerer) error
|
|
}{
|
|
{ntype: null.NetworkType, register: null.Register},
|
|
{ntype: overlay.NetworkType, register: overlay.Register},
|
|
} {
|
|
if err := nr.register(r); err != nil {
|
|
return fmt.Errorf("failed to register %q driver: %w", nr.ntype, err)
|
|
}
|
|
}
|
|
|
|
return windows.RegisterBuiltinLocalDrivers(r, store)
|
|
}
|
|
|
|
func registerPortMappers(ctx context.Context, r *drvregistry.PortMappers, cfg *config.Config) error {
|
|
return nil
|
|
}
|