mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 00:34:24 -04:00
plugin/kubernetes: clean code (#5017)
Signed-off-by: xuweiwei <xuweiwei_yewu@cmss.chinamobile.com>
This commit is contained in:
@@ -413,9 +413,9 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
|
|||||||
zonePath := msg.Path(zone, coredns)
|
zonePath := msg.Path(zone, coredns)
|
||||||
ip := ""
|
ip := ""
|
||||||
if strings.Count(podname, "-") == 3 && !strings.Contains(podname, "--") {
|
if strings.Count(podname, "-") == 3 && !strings.Contains(podname, "--") {
|
||||||
ip = strings.Replace(podname, "-", ".", -1)
|
ip = strings.ReplaceAll(podname, "-", ".")
|
||||||
} else {
|
} else {
|
||||||
ip = strings.Replace(podname, "-", ":", -1)
|
ip = strings.ReplaceAll(podname, "-", ":")
|
||||||
}
|
}
|
||||||
|
|
||||||
if k.podMode == podModeInsecure {
|
if k.podMode == podModeInsecure {
|
||||||
@@ -514,7 +514,7 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
|
|||||||
podsCount := 0
|
podsCount := 0
|
||||||
for _, ep := range endpointsListFunc() {
|
for _, ep := range endpointsListFunc() {
|
||||||
for _, eps := range ep.Subsets {
|
for _, eps := range ep.Subsets {
|
||||||
podsCount = podsCount + len(eps.Addresses)
|
podsCount += len(eps.Addresses)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -557,7 +557,7 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, p := range eps.Ports {
|
for _, p := range eps.Ports {
|
||||||
if !(match(r.port, p.Name) && match(r.protocol, string(p.Protocol))) {
|
if !(match(r.port, p.Name) && match(r.protocol, p.Protocol)) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
s := msg.Service{Host: addr.IP, Port: int(p.Port), TTL: k.ttl}
|
s := msg.Service{Host: addr.IP, Port: int(p.Port), TTL: k.ttl}
|
||||||
|
|||||||
Reference in New Issue
Block a user