Merge pull request #46364 from corhere/libn/controller-is-a-registerer

libnetwork: notify another driver registerer
This commit is contained in:
Sebastiaan van Stijn 2023-08-29 17:49:14 +02:00 committed by GitHub
commit 726dbc0f29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View file

@ -124,7 +124,7 @@ func New(cfgOptions ...config.Option) (*Controller, error) {
return nil, err
}
c.drvRegistry.Notify = c.RegisterDriver
c.drvRegistry.Notify = c
// External plugins don't need config passed through daemon. They can
// bootstrap themselves.

View file

@ -11,9 +11,6 @@ import (
// DriverWalkFunc defines the network driver table walker function signature.
type DriverWalkFunc func(name string, driver driverapi.Driver, capability driverapi.Capability) bool
// DriverNotifyFunc defines the notify function signature when a new network driver gets registered.
type DriverNotifyFunc func(name string, driver driverapi.Driver, capability driverapi.Capability) error
type driverData struct {
driver driverapi.Driver
capability driverapi.Capability
@ -23,7 +20,7 @@ type driverData struct {
// driver registry, ready to use.
type Networks struct {
// Notify is called whenever a network driver is registered.
Notify DriverNotifyFunc
Notify driverapi.Registerer
mu sync.Mutex
drivers map[string]driverData
@ -76,7 +73,7 @@ func (nr *Networks) RegisterDriver(ntype string, driver driverapi.Driver, capabi
}
if nr.Notify != nil {
if err := nr.Notify(ntype, driver, capability); err != nil {
if err := nr.Notify.RegisterDriver(ntype, driver, capability); err != nil {
return err
}
}