aboutsummaryrefslogtreecommitdiff
path: root/plugin/kubernetes/kubernetes.go
diff options
context:
space:
mode:
authorGravatar xuweiwei <xuweiwei_yewu@cmss.chinamobile.com> 2021-12-01 22:26:18 +0800
committerGravatar GitHub <noreply@github.com> 2021-12-01 09:26:18 -0500
commitb7b62b38efe281ecd17cad63765725d3ed4cbf18 (patch)
treee4301dec1b941aa1911d003f3d88ef3f9790667e /plugin/kubernetes/kubernetes.go
parent372e955980ad7a7d129ea62976daec126aa9062e (diff)
downloadcoredns-b7b62b38efe281ecd17cad63765725d3ed4cbf18.tar.gz
coredns-b7b62b38efe281ecd17cad63765725d3ed4cbf18.tar.zst
coredns-b7b62b38efe281ecd17cad63765725d3ed4cbf18.zip
plugin/kubernetes: clean code (#5017)
Signed-off-by: xuweiwei <xuweiwei_yewu@cmss.chinamobile.com>
Diffstat (limited to 'plugin/kubernetes/kubernetes.go')
-rw-r--r--plugin/kubernetes/kubernetes.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/plugin/kubernetes/kubernetes.go b/plugin/kubernetes/kubernetes.go
index 1c0c4a55d..f28f7825b 100644
--- a/plugin/kubernetes/kubernetes.go
+++ b/plugin/kubernetes/kubernetes.go
@@ -315,7 +315,7 @@ func (k *Kubernetes) endpointSliceSupported(kubeClient *kubernetes.Clientset) (b
// Disable use of endpoint slices for k8s versions 1.18 and earlier. The Endpointslices API was enabled
// by default in 1.17 but Service -> Pod proxy continued to use Endpoints by default until 1.19.
// DNS results should be built from the same source data that the proxy uses. This decision assumes
- // k8s EndpointSliceProxying featuregate is at the default (i.e. only enabled for k8s >= 1.19).
+ // k8s EndpointSliceProxying feature gate is at the default (i.e. only enabled for k8s >= 1.19).
major, _ := strconv.Atoi(sv.Major)
minor, _ := strconv.Atoi(strings.TrimRight(sv.Minor, "+"))
if major <= 1 && minor <= 18 {
@@ -413,9 +413,9 @@ func (k *Kubernetes) findPods(r recordRequest, zone string) (pods []msg.Service,
zonePath := msg.Path(zone, coredns)
ip := ""
if strings.Count(podname, "-") == 3 && !strings.Contains(podname, "--") {
- ip = strings.Replace(podname, "-", ".", -1)
+ ip = strings.ReplaceAll(podname, "-", ".")
} else {
- ip = strings.Replace(podname, "-", ":", -1)
+ ip = strings.ReplaceAll(podname, "-", ":")
}
if k.podMode == podModeInsecure {
@@ -514,7 +514,7 @@ func (k *Kubernetes) findServices(r recordRequest, zone string) (services []msg.
podsCount := 0
for _, ep := range endpointsListFunc() {
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 {
- if !(match(r.port, p.Name) && match(r.protocol, string(p.Protocol))) {
+ if !(match(r.port, p.Name) && match(r.protocol, p.Protocol)) {
continue
}
s := msg.Service{Host: addr.IP, Port: int(p.Port), TTL: k.ttl}