libnetwork/drivers: inline capabilities options
Remove the intermediate variable, and move the option closer to where it's used, as in some cases we created the variable, but could return with an error before it was used. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
97285711f3
commit
40908c5fcd
11 changed files with 32 additions and 49 deletions
|
@ -174,12 +174,10 @@ func Register(r driverapi.Registerer, config map[string]interface{}) error {
|
|||
if err := d.configure(config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
c := driverapi.Capability{
|
||||
return r.RegisterDriver(networkType, d, driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.LocalScope,
|
||||
}
|
||||
return r.RegisterDriver(networkType, d, c)
|
||||
})
|
||||
}
|
||||
|
||||
// Validate performs a static validation on the network configuration parameters.
|
||||
|
|
|
@ -20,11 +20,10 @@ func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
|
|||
|
||||
// Register registers a new instance of the bridge manager driver with r.
|
||||
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.LocalScope,
|
||||
}
|
||||
return r.RegisterDriver(networkType, &driver{}, c)
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||
|
|
|
@ -24,11 +24,10 @@ func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
|
|||
}
|
||||
|
||||
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.LocalScope,
|
||||
}
|
||||
return r.RegisterDriver(networkType, &driver{}, c)
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||
|
|
|
@ -64,18 +64,16 @@ type network struct {
|
|||
|
||||
// Register initializes and registers the libnetwork ipvlan driver.
|
||||
func Register(r driverapi.Registerer, config map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
}
|
||||
d := &driver{
|
||||
networks: networkTable{},
|
||||
}
|
||||
if err := d.initStore(config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return r.RegisterDriver(driverName, d, c)
|
||||
return r.RegisterDriver(driverName, d, driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||
|
|
|
@ -20,11 +20,10 @@ func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
|
|||
|
||||
// Register registers a new instance of the ipvlan manager driver.
|
||||
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
}
|
||||
return r.RegisterDriver(networkType, &driver{}, c)
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||
|
|
|
@ -58,18 +58,16 @@ type network struct {
|
|||
|
||||
// Register initializes and registers the libnetwork macvlan driver
|
||||
func Register(r driverapi.Registerer, config map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
}
|
||||
d := &driver{
|
||||
networks: networkTable{},
|
||||
}
|
||||
if err := d.initStore(config); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return r.RegisterDriver(driverName, d, c)
|
||||
return r.RegisterDriver(driverName, d, driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||
|
|
|
@ -20,11 +20,10 @@ func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
|
|||
|
||||
// Register registers a new instance of the macvlan manager driver.
|
||||
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
}
|
||||
return r.RegisterDriver(networkType, &driver{}, c)
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||
|
|
|
@ -18,10 +18,9 @@ type driver struct {
|
|||
|
||||
// Register registers a new instance of the null driver.
|
||||
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
return r.RegisterDriver(networkType, &driver{}, driverapi.Capability{
|
||||
DataScope: datastore.LocalScope,
|
||||
}
|
||||
return r.RegisterDriver(networkType, &driver{}, c)
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||
|
|
|
@ -39,10 +39,6 @@ type driver struct {
|
|||
|
||||
// Register registers a new instance of the overlay driver.
|
||||
func Register(r driverapi.Registerer, config map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
DataScope: datastore.GlobalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
}
|
||||
d := &driver{
|
||||
networks: networkTable{},
|
||||
peerDb: peerNetworkMap{
|
||||
|
@ -51,8 +47,10 @@ func Register(r driverapi.Registerer, config map[string]interface{}) error {
|
|||
secMap: &encrMap{nodes: map[string][]*spi{}},
|
||||
config: config,
|
||||
}
|
||||
|
||||
return r.RegisterDriver(networkType, d, c)
|
||||
return r.RegisterDriver(networkType, d, driverapi.Capability{
|
||||
DataScope: datastore.GlobalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) configure() error {
|
||||
|
|
|
@ -54,11 +54,6 @@ func Init(dc driverapi.DriverCallback, _ map[string]interface{}) error {
|
|||
// Register registers a new instance of the overlay driver.
|
||||
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
|
||||
var err error
|
||||
c := driverapi.Capability{
|
||||
DataScope: datastore.GlobalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
}
|
||||
|
||||
d := &driver{
|
||||
networks: networkTable{},
|
||||
}
|
||||
|
@ -68,7 +63,10 @@ func Register(r driverapi.Registerer, _ map[string]interface{}) error {
|
|||
return fmt.Errorf("failed to initialize vxlan id manager: %v", err)
|
||||
}
|
||||
|
||||
return r.RegisterDriver(networkType, d, c)
|
||||
return r.RegisterDriver(networkType, d, driverapi.Capability{
|
||||
DataScope: datastore.GlobalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) NetworkAllocate(id string, option map[string]string, ipV4Data, ipV6Data []driverapi.IPAMData) (map[string]string, error) {
|
||||
|
|
|
@ -27,18 +27,16 @@ type driver struct {
|
|||
|
||||
// Register registers a new instance of the overlay driver.
|
||||
func Register(r driverapi.Registerer, _ map[string]interface{}) error {
|
||||
c := driverapi.Capability{
|
||||
DataScope: datastore.GlobalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
}
|
||||
|
||||
d := &driver{
|
||||
networks: networkTable{},
|
||||
}
|
||||
|
||||
d.restoreHNSNetworks()
|
||||
|
||||
return r.RegisterDriver(networkType, d, c)
|
||||
return r.RegisterDriver(networkType, d, driverapi.Capability{
|
||||
DataScope: datastore.GlobalScope,
|
||||
ConnectivityScope: datastore.GlobalScope,
|
||||
})
|
||||
}
|
||||
|
||||
func (d *driver) restoreHNSNetworks() error {
|
||||
|
|
Loading…
Add table
Reference in a new issue