Browse Source

libnetwork/ipam(s): format code with gofumpt

Formatting the code with https://github.com/mvdan/gofumpt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 3 years ago
parent
commit
6f3fcbcfe1

+ 5 - 5
libnetwork/ipam/allocator_test.go

@@ -514,7 +514,8 @@ func TestRequestReleaseAddressFromSubPool(t *testing.T) {
 
 func TestSerializeRequestReleaseAddressFromSubPool(t *testing.T) {
 	opts := map[string]string{
-		ipamapi.AllocSerialPrefix: "true"}
+		ipamapi.AllocSerialPrefix: "true",
+	}
 	a, err := NewAllocator(ipamutils.GetLocalScopeDefaultNetworks(), ipamutils.GetGlobalScopeDefaultNetworks())
 	assert.NilError(t, err)
 
@@ -641,7 +642,8 @@ func TestGetAddress(t *testing.T) {
 		/*"10.0.0.0/8", "10.0.0.0/9", "10.0.0.0/10",*/ "10.0.0.0/11", "10.0.0.0/12", "10.0.0.0/13", "10.0.0.0/14",
 		"10.0.0.0/15", "10.0.0.0/16", "10.0.0.0/17", "10.0.0.0/18", "10.0.0.0/19", "10.0.0.0/20", "10.0.0.0/21",
 		"10.0.0.0/22", "10.0.0.0/23", "10.0.0.0/24", "10.0.0.0/25", "10.0.0.0/26", "10.0.0.0/27", "10.0.0.0/28",
-		"10.0.0.0/29", "10.0.0.0/30", "10.0.0.0/31"}
+		"10.0.0.0/29", "10.0.0.0/30", "10.0.0.0/31",
+	}
 
 	for _, subnet := range input {
 		assertGetAddress(t, subnet)
@@ -881,9 +883,7 @@ func TestUnusualSubnets(t *testing.T) {
 }
 
 func TestRelease(t *testing.T) {
-	var (
-		subnet = "192.168.0.0/23"
-	)
+	subnet := "192.168.0.0/23"
 
 	a, err := NewAllocator(ipamutils.GetLocalScopeDefaultNetworks(), ipamutils.GetGlobalScopeDefaultNetworks())
 	assert.NilError(t, err)

+ 2 - 4
libnetwork/ipams/builtin/builtin.go

@@ -8,10 +8,8 @@ import (
 	"github.com/docker/docker/libnetwork/ipamutils"
 )
 
-var (
-	// defaultAddressPool Stores user configured subnet list
-	defaultAddressPool []*net.IPNet
-)
+// defaultAddressPool Stores user configured subnet list
+var defaultAddressPool []*net.IPNet
 
 // registerBuiltin registers the built-in ipam driver with libnetwork.
 func registerBuiltin(ic ipamapi.Registerer) error {

+ 6 - 6
libnetwork/ipams/remote/remote_test.go

@@ -41,7 +41,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
 		specPath = filepath.Join(os.Getenv("programdata"), "docker", "plugins")
 	}
 
-	if err := os.MkdirAll(specPath, 0755); err != nil {
+	if err := os.MkdirAll(specPath, 0o755); err != nil {
 		t.Fatal(err)
 	}
 
@@ -56,7 +56,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
 		t.Fatal("Failed to start an HTTP Server")
 	}
 
-	if err := os.WriteFile(filepath.Join(specPath, name+".spec"), []byte(server.URL), 0644); err != nil {
+	if err := os.WriteFile(filepath.Join(specPath, name+".spec"), []byte(server.URL), 0o644); err != nil {
 		t.Fatal(err)
 	}
 
@@ -74,7 +74,7 @@ func setupPlugin(t *testing.T, name string, mux *http.ServeMux) func() {
 }
 
 func TestGetCapabilities(t *testing.T) {
-	var plugin = "test-ipam-driver-capabilities"
+	plugin := "test-ipam-driver-capabilities"
 
 	mux := http.NewServeMux()
 	defer setupPlugin(t, plugin, mux)()
@@ -107,7 +107,7 @@ func TestGetCapabilities(t *testing.T) {
 }
 
 func TestGetCapabilitiesFromLegacyDriver(t *testing.T) {
-	var plugin = "test-ipam-legacy-driver"
+	plugin := "test-ipam-legacy-driver"
 
 	mux := http.NewServeMux()
 	defer setupPlugin(t, plugin, mux)()
@@ -130,7 +130,7 @@ func TestGetCapabilitiesFromLegacyDriver(t *testing.T) {
 }
 
 func TestGetDefaultAddressSpaces(t *testing.T) {
-	var plugin = "test-ipam-driver-addr-spaces"
+	plugin := "test-ipam-driver-addr-spaces"
 
 	mux := http.NewServeMux()
 	defer setupPlugin(t, plugin, mux)()
@@ -164,7 +164,7 @@ func TestGetDefaultAddressSpaces(t *testing.T) {
 }
 
 func TestRemoteDriver(t *testing.T) {
-	var plugin = "test-ipam-driver"
+	plugin := "test-ipam-driver"
 
 	mux := http.NewServeMux()
 	defer setupPlugin(t, plugin, mux)()

+ 2 - 6
libnetwork/ipams/windowsipam/windowsipam.go

@@ -17,12 +17,9 @@ const (
 // DefaultIPAM defines the default ipam-driver for local-scoped windows networks
 const DefaultIPAM = "windows"
 
-var (
-	defaultPool, _ = types.ParseCIDR("0.0.0.0/0")
-)
+var defaultPool, _ = types.ParseCIDR("0.0.0.0/0")
 
-type allocator struct {
-}
+type allocator struct{}
 
 // Register registers the built-in ipam service with libnetwork
 func Register(ipamName string, r ipamapi.Registerer) error {
@@ -67,7 +64,6 @@ func (a *allocator) ReleasePool(poolID string) error {
 func (a *allocator) RequestAddress(poolID string, prefAddress net.IP, opts map[string]string) (*net.IPNet, map[string]string, error) {
 	log.G(context.TODO()).Debugf("RequestAddress(%s, %v, %v)", poolID, prefAddress, opts)
 	_, ipNet, err := net.ParseCIDR(poolID)
-
 	if err != nil {
 		return nil, nil, err
 	}