Browse code

libnetwork: fix some linting issues

- fix incorrectly formatted GoDoc and comments
- rename a variable that collided with the `cap` built-in

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2021/08/26 17:02:04
Showing 1 changed files
... ...
@@ -26,16 +26,16 @@ import (
26 26
 // A Network represents a logical connectivity zone that containers may
27 27
 // join using the Link method. A Network is managed by a specific driver.
28 28
 type Network interface {
29
-	// A user chosen name for this network.
29
+	// Name returns a user chosen name for this network.
30 30
 	Name() string
31 31
 
32
-	// A system generated id for this network.
32
+	// ID returns a system generated id for this network.
33 33
 	ID() string
34 34
 
35
-	// The type of network, which corresponds to its managing driver.
35
+	// Type returns the type of network, which corresponds to its managing driver.
36 36
 	Type() string
37 37
 
38
-	// Create a new endpoint to this network symbolically identified by the
38
+	// CreateEndpoint creates a new endpoint to this network symbolically identified by the
39 39
 	// specified unique name. The options parameter carries driver specific options.
40 40
 	CreateEndpoint(name string, options ...EndpointOption) (Endpoint, error)
41 41
 
... ...
@@ -45,7 +45,7 @@ type Network interface {
45 45
 	// Endpoints returns the list of Endpoint(s) in this network.
46 46
 	Endpoints() []Endpoint
47 47
 
48
-	// WalkEndpoints uses the provided function to walk the Endpoints
48
+	// WalkEndpoints uses the provided function to walk the Endpoints.
49 49
 	WalkEndpoints(walker EndpointWalker)
50 50
 
51 51
 	// EndpointByName returns the Endpoint which has the passed name. If not found, the error ErrNoSuchEndpoint is returned.
... ...
@@ -54,7 +54,7 @@ type Network interface {
54 54
 	// EndpointByID returns the Endpoint which has the passed id. If not found, the error ErrNoSuchEndpoint is returned.
55 55
 	EndpointByID(id string) (Endpoint, error)
56 56
 
57
-	// Return certain operational data belonging to this network
57
+	// Info returns certain operational data belonging to this network.
58 58
 	Info() NetworkInfo
59 59
 }
60 60
 
... ...
@@ -78,8 +78,8 @@ type NetworkInfo interface {
78 78
 	// gossip cluster. For non-dynamic overlay networks and bridge networks it returns an
79 79
 	// empty slice
80 80
 	Peers() []networkdb.PeerInfo
81
-	//Services returns a map of services keyed by the service name with the details
82
-	//of all the tasks that belong to the service. Applicable only in swarm mode.
81
+	// Services returns a map of services keyed by the service name with the details
82
+	// of all the tasks that belong to the service. Applicable only in swarm mode.
83 83
 	Services() map[string]ServiceInfo
84 84
 }
85 85
 
... ...
@@ -89,7 +89,7 @@ type EndpointWalker func(ep Endpoint) bool
89 89
 
90 90
 // ipInfo is the reverse mapping from IP to service name to serve the PTR query.
91 91
 // extResolver is set if an external server resolves a service name to this IP.
92
-// Its an indication to defer PTR queries also to that external server.
92
+// It's an indication to defer PTR queries also to that external server.
93 93
 type ipInfo struct {
94 94
 	name        string
95 95
 	serviceID   string
... ...
@@ -130,15 +130,15 @@ type networkDBTable struct {
130 130
 
131 131
 // IpamConf contains all the ipam related configurations for a network
132 132
 type IpamConf struct {
133
-	// The master address pool for containers and network interfaces
133
+	// PreferredPool is the master address pool for containers and network interfaces.
134 134
 	PreferredPool string
135
-	// A subset of the master pool. If specified,
136
-	// this becomes the container pool
135
+	// SubPool is a subset of the master pool. If specified,
136
+	// this becomes the container pool.
137 137
 	SubPool string
138
-	// Preferred Network Gateway address (optional)
138
+	// Gateway is the preferred Network Gateway address (optional).
139 139
 	Gateway string
140
-	// Auxiliary addresses for network driver. Must be within the master pool.
141
-	// libnetwork will reserve them if they fall into the container pool
140
+	// AuxAddresses contains auxiliary addresses for network driver. Must be within the master pool.
141
+	// libnetwork will reserve them if they fall into the container pool.
142 142
 	AuxAddresses map[string]string
143 143
 }
144 144
 
... ...
@@ -415,7 +415,7 @@ func (n *network) validateConfiguration() error {
415 415
 	return nil
416 416
 }
417 417
 
418
-// Applies network specific configurations
418
+// applyConfigurationTo applies network specific configurations.
419 419
 func (n *network) applyConfigurationTo(to *network) error {
420 420
 	to.enableIPv6 = n.enableIPv6
421 421
 	if len(n.labels) > 0 {
... ...
@@ -1197,12 +1197,12 @@ func (n *network) createEndpoint(name string, options ...EndpointOption) (Endpoi
1197 1197
 		}
1198 1198
 	}
1199 1199
 
1200
-	ipam, cap, err := n.getController().getIPAMDriver(n.ipamType)
1200
+	ipam, capability, err := n.getController().getIPAMDriver(n.ipamType)
1201 1201
 	if err != nil {
1202 1202
 		return nil, err
1203 1203
 	}
1204 1204
 
1205
-	if cap.RequiresMACAddress {
1205
+	if capability.RequiresMACAddress {
1206 1206
 		if ep.iface.mac == nil {
1207 1207
 			ep.iface.mac = netutils.GenerateRandomMAC()
1208 1208
 		}
... ...
@@ -2236,14 +2236,14 @@ func (n *network) deleteLoadBalancerSandbox() error {
2236 2236
 			if sb != nil {
2237 2237
 				if err := sb.DisableService(); err != nil {
2238 2238
 					logrus.Warnf("Failed to disable service on sandbox %s: %v", sandboxName, err)
2239
-					//Ignore error and attempt to delete the load balancer endpoint
2239
+					// Ignore error and attempt to delete the load balancer endpoint
2240 2240
 				}
2241 2241
 			}
2242 2242
 		}
2243 2243
 
2244 2244
 		if err := endpoint.Delete(true); err != nil {
2245 2245
 			logrus.Warnf("Failed to delete endpoint %s (%s) in %s: %v", endpoint.Name(), endpoint.ID(), sandboxName, err)
2246
-			//Ignore error and attempt to delete the sandbox.
2246
+			// Ignore error and attempt to delete the sandbox.
2247 2247
 		}
2248 2248
 	}
2249 2249