Selaa lähdekoodia

Merge pull request #46239 from thaJeztah/vars_collide

libnetwork:  rename vars that collided
Sebastiaan van Stijn 1 vuosi sitten
vanhempi
commit
331854a126
3 muutettua tiedostoa jossa 14 lisäystä ja 14 poistoa
  1. 4 4
      libnetwork/agent.go
  2. 8 8
      libnetwork/controller.go
  3. 2 2
      libnetwork/drvregistry/ipams_test.go

+ 4 - 4
libnetwork/agent.go

@@ -35,7 +35,7 @@ func (b ByTime) Len() int           { return len(b) }
 func (b ByTime) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
 func (b ByTime) Swap(i, j int)      { b[i], b[j] = b[j], b[i] }
 func (b ByTime) Less(i, j int) bool { return b[i].LamportTime < b[j].LamportTime }
 func (b ByTime) Less(i, j int) bool { return b[i].LamportTime < b[j].LamportTime }
 
 
-type agent struct {
+type nwAgent struct {
 	networkDB         *networkdb.NetworkDB
 	networkDB         *networkdb.NetworkDB
 	bindAddr          string
 	bindAddr          string
 	advertiseAddr     string
 	advertiseAddr     string
@@ -45,7 +45,7 @@ type agent struct {
 	sync.Mutex
 	sync.Mutex
 }
 }
 
 
-func (a *agent) dataPathAddress() string {
+func (a *nwAgent) dataPathAddress() string {
 	a.Lock()
 	a.Lock()
 	defer a.Unlock()
 	defer a.Unlock()
 	if a.dataPathAddr != "" {
 	if a.dataPathAddr != "" {
@@ -323,7 +323,7 @@ func (c *Controller) agentInit(listenAddr, bindAddrOrInterface, advertiseAddr, d
 	cancelList = append(cancelList, cancel)
 	cancelList = append(cancelList, cancel)
 
 
 	c.mu.Lock()
 	c.mu.Lock()
-	c.agent = &agent{
+	c.agent = &nwAgent{
 		networkDB:         nDB,
 		networkDB:         nDB,
 		bindAddr:          bindAddr,
 		bindAddr:          bindAddr,
 		advertiseAddr:     advertiseAddr,
 		advertiseAddr:     advertiseAddr,
@@ -750,7 +750,7 @@ func (ep *Endpoint) deleteServiceInfoFromCluster(sb *Sandbox, fullRemove bool, m
 	return nil
 	return nil
 }
 }
 
 
-func disableServiceInNetworkDB(a *agent, n *Network, ep *Endpoint) {
+func disableServiceInNetworkDB(a *nwAgent, n *Network, ep *Endpoint) {
 	var epRec EndpointRecord
 	var epRec EndpointRecord
 
 
 	log.G(context.TODO()).Debugf("disableServiceInNetworkDB for %s %s", ep.svcName, ep.ID())
 	log.G(context.TODO()).Debugf("disableServiceInNetworkDB for %s %s", ep.svcName, ep.ID())

+ 8 - 8
libnetwork/controller.go

@@ -95,7 +95,7 @@ type Controller struct {
 	defOsSbox        osl.Sandbox
 	defOsSbox        osl.Sandbox
 	ingressSandbox   *Sandbox
 	ingressSandbox   *Sandbox
 	sboxOnce         sync.Once
 	sboxOnce         sync.Once
-	agent            *agent
+	agent            *nwAgent
 	networkLocker    *locker.Locker
 	networkLocker    *locker.Locker
 	agentInitDone    chan struct{}
 	agentInitDone    chan struct{}
 	agentStopDone    chan struct{}
 	agentStopDone    chan struct{}
@@ -207,7 +207,7 @@ func (c *Controller) SetKeys(keys []*types.EncryptionKey) error {
 	return c.handleKeyChange(keys)
 	return c.handleKeyChange(keys)
 }
 }
 
 
-func (c *Controller) getAgent() *agent {
+func (c *Controller) getAgent() *nwAgent {
 	c.mu.Lock()
 	c.mu.Lock()
 	defer c.mu.Unlock()
 	defer c.mu.Unlock()
 	return c.agent
 	return c.agent
@@ -368,7 +368,7 @@ func (c *Controller) BuiltinDrivers() []string {
 // BuiltinIPAMDrivers returns the list of builtin ipam drivers.
 // BuiltinIPAMDrivers returns the list of builtin ipam drivers.
 func (c *Controller) BuiltinIPAMDrivers() []string {
 func (c *Controller) BuiltinIPAMDrivers() []string {
 	drivers := []string{}
 	drivers := []string{}
-	c.ipamRegistry.WalkIPAMs(func(name string, driver ipamapi.Ipam, cap *ipamapi.Capability) bool {
+	c.ipamRegistry.WalkIPAMs(func(name string, driver ipamapi.Ipam, _ *ipamapi.Capability) bool {
 		if driver.IsBuiltIn() {
 		if driver.IsBuiltIn() {
 			drivers = append(drivers, name)
 			drivers = append(drivers, name)
 		}
 		}
@@ -386,14 +386,14 @@ func (c *Controller) processNodeDiscovery(nodes []net.IP, add bool) {
 	})
 	})
 }
 }
 
 
-func (c *Controller) pushNodeDiscovery(d discoverapi.Discover, cap driverapi.Capability, nodes []net.IP, add bool) {
+func (c *Controller) pushNodeDiscovery(d discoverapi.Discover, capability driverapi.Capability, nodes []net.IP, add bool) {
 	var self net.IP
 	var self net.IP
 	// try swarm-mode config
 	// try swarm-mode config
 	if agent := c.getAgent(); agent != nil {
 	if agent := c.getAgent(); agent != nil {
 		self = net.ParseIP(agent.advertiseAddr)
 		self = net.ParseIP(agent.advertiseAddr)
 	}
 	}
 
 
-	if d == nil || cap.ConnectivityScope != scope.Global || nodes == nil {
+	if d == nil || capability.ConnectivityScope != scope.Global || nodes == nil {
 		return
 		return
 	}
 	}
 
 
@@ -1066,7 +1066,7 @@ func (c *Controller) loadIPAMDriver(name string) error {
 }
 }
 
 
 func (c *Controller) getIPAMDriver(name string) (ipamapi.Ipam, *ipamapi.Capability, error) {
 func (c *Controller) getIPAMDriver(name string) (ipamapi.Ipam, *ipamapi.Capability, error) {
-	id, cap := c.ipamRegistry.IPAM(name)
+	id, caps := c.ipamRegistry.IPAM(name)
 	if id == nil {
 	if id == nil {
 		// Might be a plugin name. Try loading it
 		// Might be a plugin name. Try loading it
 		if err := c.loadIPAMDriver(name); err != nil {
 		if err := c.loadIPAMDriver(name); err != nil {
@@ -1074,13 +1074,13 @@ func (c *Controller) getIPAMDriver(name string) (ipamapi.Ipam, *ipamapi.Capabili
 		}
 		}
 
 
 		// Now that we resolved the plugin, try again looking up the registry
 		// Now that we resolved the plugin, try again looking up the registry
-		id, cap = c.ipamRegistry.IPAM(name)
+		id, caps = c.ipamRegistry.IPAM(name)
 		if id == nil {
 		if id == nil {
 			return nil, nil, types.InvalidParameterErrorf("invalid ipam driver: %q", name)
 			return nil, nil, types.InvalidParameterErrorf("invalid ipam driver: %q", name)
 		}
 		}
 	}
 	}
 
 
-	return id, cap, nil
+	return id, caps, nil
 }
 }
 
 
 // Stop stops the network controller.
 // Stop stops the network controller.

+ 2 - 2
libnetwork/drvregistry/ipams_test.go

@@ -27,9 +27,9 @@ func TestIPAMs(t *testing.T) {
 	t.Run("IPAM", func(t *testing.T) {
 	t.Run("IPAM", func(t *testing.T) {
 		reg := getNewIPAMs(t)
 		reg := getNewIPAMs(t)
 
 
-		i, cap := reg.IPAM("default")
+		i, caps := reg.IPAM("default")
 		assert.Check(t, i != nil)
 		assert.Check(t, i != nil)
-		assert.Check(t, cap != nil)
+		assert.Check(t, caps != nil)
 	})
 	})
 
 
 	t.Run("WalkIPAMs", func(t *testing.T) {
 	t.Run("WalkIPAMs", func(t *testing.T) {