Skip to content

Commit

Permalink
libnet/ipams/null: move driver name to its pkg
Browse files Browse the repository at this point in the history
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
  • Loading branch information
akerouanton committed Apr 26, 2024
1 parent f2387f3 commit c5376e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 0 additions & 2 deletions libnetwork/ipamapi/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import (

// IPAM plugin types
const (
// NullIPAM is the name of the built-in null ipam driver
NullIPAM = "null"
// PluginEndpointType represents the Endpoint Type used by Plugin system
PluginEndpointType = "IpamDriver"
// RequestAddressType represents the Address Type used when requesting an address
Expand Down
5 changes: 4 additions & 1 deletion libnetwork/ipams/null/null.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import (
)

const (
// DriverName is the name of the built-in null ipam driver
DriverName = "null"

defaultAddressSpace = "null"
defaultPoolCIDR = "0.0.0.0/0"
defaultPoolID = defaultAddressSpace + "/" + defaultPoolCIDR
Expand Down Expand Up @@ -67,5 +70,5 @@ func (a *allocator) IsBuiltIn() bool {

// Register registers the null ipam driver with r.
func Register(r ipamapi.Registerer) error {
return r.RegisterIpamDriver(ipamapi.NullIPAM, &allocator{})
return r.RegisterIpamDriver(DriverName, &allocator{})
}
4 changes: 2 additions & 2 deletions libnetwork/libnetwork_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"github.com/docker/docker/libnetwork/config"
"github.com/docker/docker/libnetwork/datastore"
"github.com/docker/docker/libnetwork/driverapi"
"github.com/docker/docker/libnetwork/ipamapi"
"github.com/docker/docker/libnetwork/ipams/defaultipam"
"github.com/docker/docker/libnetwork/ipams/null"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/libnetwork/options"
"github.com/docker/docker/libnetwork/osl"
Expand Down Expand Up @@ -2119,7 +2119,7 @@ func TestNullIpam(t *testing.T) {
defer netnsutils.SetupTestOSContext(t)()
controller := newController(t)

_, err := controller.NewNetwork(bridgeNetType, "testnetworkinternal", "", libnetwork.NetworkOptionIpam(ipamapi.NullIPAM, "", nil, nil, nil))
_, err := controller.NewNetwork(bridgeNetType, "testnetworkinternal", "", libnetwork.NetworkOptionIpam(null.DriverName, "", nil, nil, nil))
if err == nil || err.Error() != "ipv4 pool is empty" {
t.Fatal("bridge network should complain empty pool")
}
Expand Down

0 comments on commit c5376e5

Please sign in to comment.