Merge pull request #46239 from thaJeztah/vars_collide

libnetwork:  rename vars that collided
This commit is contained in:
Sebastiaan van Stijn 2023-08-22 10:50:35 +02:00 committed by GitHub
commit 331854a126
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 14 deletions

View file

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

View file

@ -95,7 +95,7 @@ type Controller struct {
defOsSbox osl.Sandbox
ingressSandbox *Sandbox
sboxOnce sync.Once
agent *agent
agent *nwAgent
networkLocker *locker.Locker
agentInitDone chan struct{}
agentStopDone chan struct{}
@ -207,7 +207,7 @@ func (c *Controller) SetKeys(keys []*types.EncryptionKey) error {
return c.handleKeyChange(keys)
}
func (c *Controller) getAgent() *agent {
func (c *Controller) getAgent() *nwAgent {
c.mu.Lock()
defer c.mu.Unlock()
return c.agent
@ -368,7 +368,7 @@ func (c *Controller) BuiltinDrivers() []string {
// BuiltinIPAMDrivers returns the list of builtin ipam drivers.
func (c *Controller) BuiltinIPAMDrivers() []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() {
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
// try swarm-mode config
if agent := c.getAgent(); agent != nil {
self = net.ParseIP(agent.advertiseAddr)
}
if d == nil || cap.ConnectivityScope != scope.Global || nodes == nil {
if d == nil || capability.ConnectivityScope != scope.Global || nodes == nil {
return
}
@ -1066,7 +1066,7 @@ func (c *Controller) loadIPAMDriver(name string) 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 {
// Might be a plugin name. Try loading it
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
id, cap = c.ipamRegistry.IPAM(name)
id, caps = c.ipamRegistry.IPAM(name)
if id == nil {
return nil, nil, types.InvalidParameterErrorf("invalid ipam driver: %q", name)
}
}
return id, cap, nil
return id, caps, nil
}
// Stop stops the network controller.

View file

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