libnetwork: Sandbox.resolveName: rename vars for clarity
- use `nameOrAlias` for the name (or alias) to resolve - use `lookupAlias` to indicate what the intent is; this function is either looking up aliases or "regular" names. Ideally we would split the function, but let's keep that for a future exercise. - name the `ipv6Miss` output variable. The "ipv6 miss" logic is rather confusing, and should probably be revisited, but let's start with giving the variable a name to make it more apparent what it is. - use `nw` for networks, which is the more common local name Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
4401ccac22
commit
9249b34be8
1 changed files with 8 additions and 12 deletions
|
@ -488,25 +488,23 @@ func (sb *Sandbox) ResolveName(name string, ipType int) ([]net.IP, bool) {
|
|||
return nil, false
|
||||
}
|
||||
|
||||
func (sb *Sandbox) resolveName(req string, networkName string, epList []*Endpoint, alias bool, ipType int) ([]net.IP, bool) {
|
||||
var ipv6Miss bool
|
||||
|
||||
func (sb *Sandbox) resolveName(nameOrAlias string, networkName string, epList []*Endpoint, lookupAlias bool, ipType int) (_ []net.IP, ipv6Miss bool) {
|
||||
for _, ep := range epList {
|
||||
name := req
|
||||
n := ep.getNetwork()
|
||||
name := nameOrAlias
|
||||
nw := ep.getNetwork()
|
||||
|
||||
if networkName != "" && networkName != n.Name() {
|
||||
if networkName != "" && networkName != nw.Name() {
|
||||
continue
|
||||
}
|
||||
|
||||
if alias {
|
||||
if lookupAlias {
|
||||
if ep.aliases == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var ok bool
|
||||
ep.mu.Lock()
|
||||
name, ok = ep.aliases[req]
|
||||
name, ok = ep.aliases[nameOrAlias]
|
||||
ep.mu.Unlock()
|
||||
if !ok {
|
||||
continue
|
||||
|
@ -515,19 +513,17 @@ func (sb *Sandbox) resolveName(req string, networkName string, epList []*Endpoin
|
|||
// If it is a regular lookup and if the requested name is an alias
|
||||
// don't perform a svc lookup for this endpoint.
|
||||
ep.mu.Lock()
|
||||
if _, ok := ep.aliases[req]; ok {
|
||||
if _, ok := ep.aliases[nameOrAlias]; ok {
|
||||
ep.mu.Unlock()
|
||||
continue
|
||||
}
|
||||
ep.mu.Unlock()
|
||||
}
|
||||
|
||||
ip, miss := n.ResolveName(name, ipType)
|
||||
|
||||
ip, miss := nw.ResolveName(name, ipType)
|
||||
if ip != nil {
|
||||
return ip, false
|
||||
}
|
||||
|
||||
if miss {
|
||||
ipv6Miss = miss
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue