fix: remove unnecessary conversion (#6258)
Signed-off-by: Zhizhen He <hezhizhen.yi@gmail.com>
This commit is contained in:
parent
141c760846
commit
5de473da1c
15 changed files with 20 additions and 19 deletions
|
@ -10,3 +10,4 @@ linters:
|
||||||
- whitespace
|
- whitespace
|
||||||
- unused
|
- unused
|
||||||
- gofmt
|
- gofmt
|
||||||
|
- unconvert
|
||||||
|
|
|
@ -145,7 +145,7 @@ func TestAzure(t *testing.T) {
|
||||||
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
|
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if code != int(tc.wantRetCode) {
|
if code != tc.wantRetCode {
|
||||||
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
|
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ func TestChaos(t *testing.T) {
|
||||||
if err != tc.expectedErr {
|
if err != tc.expectedErr {
|
||||||
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
|
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
|
||||||
}
|
}
|
||||||
if code != int(tc.expectedCode) {
|
if code != tc.expectedCode {
|
||||||
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
||||||
}
|
}
|
||||||
if tc.expectedReply != "" {
|
if tc.expectedReply != "" {
|
||||||
|
|
|
@ -292,7 +292,7 @@ func TestCloudDNS(t *testing.T) {
|
||||||
if err != tc.expectedErr {
|
if err != tc.expectedErr {
|
||||||
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
|
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
|
||||||
}
|
}
|
||||||
if code != int(tc.wantRetCode) {
|
if code != tc.wantRetCode {
|
||||||
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
|
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ func TestBlackLiesBitmapNoData(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, b := range nsec.TypeBitMap {
|
for _, b := range nsec.TypeBitMap {
|
||||||
if uint16(b) == dns.TypeTLSA {
|
if b == dns.TypeTLSA {
|
||||||
t.Errorf("Type TLSA should not be present in the type bitmap: %v", nsec.TypeBitMap)
|
t.Errorf("Type TLSA should not be present in the type bitmap: %v", nsec.TypeBitMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func TestBlackLiesBitmapNameError(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, b := range nsec.TypeBitMap {
|
for _, b := range nsec.TypeBitMap {
|
||||||
if uint16(b) == dns.TypeTLSA {
|
if b == dns.TypeTLSA {
|
||||||
t.Errorf("Type TLSA should not be present in the type bitmap: %v", nsec.TypeBitMap)
|
t.Errorf("Type TLSA should not be present in the type bitmap: %v", nsec.TypeBitMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ func TestErraticDrop(t *testing.T) {
|
||||||
if err != tc.expectedErr {
|
if err != tc.expectedErr {
|
||||||
t.Errorf("Test %d: Expected error %q, but got %q", i, tc.expectedErr, err)
|
t.Errorf("Test %d: Expected error %q, but got %q", i, tc.expectedErr, err)
|
||||||
}
|
}
|
||||||
if code != int(tc.expectedCode) {
|
if code != tc.expectedCode {
|
||||||
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ func TestErraticTruncate(t *testing.T) {
|
||||||
if err != tc.expectedErr {
|
if err != tc.expectedErr {
|
||||||
t.Errorf("Test %d: Expected error %q, but got %q", i, tc.expectedErr, err)
|
t.Errorf("Test %d: Expected error %q, but got %q", i, tc.expectedErr, err)
|
||||||
}
|
}
|
||||||
if code != int(tc.expectedCode) {
|
if code != tc.expectedCode {
|
||||||
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ func newOptions() *options {
|
||||||
return &options{
|
return &options{
|
||||||
autoReverse: true,
|
autoReverse: true,
|
||||||
ttl: 3600,
|
ttl: 3600,
|
||||||
reload: time.Duration(5 * time.Second),
|
reload: 5 * time.Second,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,7 @@ func (k *Kubernetes) ExternalServices(zone string, headless bool) (services []ms
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
s.Host = msg.Domain(s.Key)
|
s.Host = msg.Domain(s.Key)
|
||||||
s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/")
|
s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+p.Protocol), strings.ToLower("_"+p.Name)), "/")
|
||||||
headlessServices[strings.Join([]string{s.Key, PortProtocol}, "/")] = append(headlessServices[strings.Join([]string{s.Key, PortProtocol}, "/")], s)
|
headlessServices[strings.Join([]string{s.Key, PortProtocol}, "/")] = append(headlessServices[strings.Join([]string{s.Key, PortProtocol}, "/")], s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ func (k *Kubernetes) ExternalServices(zone string, headless bool) (services []ms
|
||||||
s := msg.Service{Host: ip, Port: int(p.Port), TTL: k.ttl}
|
s := msg.Service{Host: ip, Port: int(p.Port), TTL: k.ttl}
|
||||||
s.Key = strings.Join([]string{zonePath, svc.Namespace, svc.Name}, "/")
|
s.Key = strings.Join([]string{zonePath, svc.Namespace, svc.Name}, "/")
|
||||||
services = append(services, s)
|
services = append(services, s)
|
||||||
s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/")
|
s.Key = strings.Join(append([]string{zonePath, svc.Namespace, svc.Name}, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+p.Name)), "/")
|
||||||
s.TargetStrip = 2
|
s.TargetStrip = 2
|
||||||
services = append(services, s)
|
services = append(services, s)
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, erro
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Key = strings.Join(append(svcBase, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/")
|
s.Key = strings.Join(append(svcBase, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+p.Name)), "/")
|
||||||
|
|
||||||
ch <- []dns.RR{s.NewSRV(msg.Domain(s.Key), 100)}
|
ch <- []dns.RR{s.NewSRV(msg.Domain(s.Key), 100)}
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ func (k *Kubernetes) Transfer(zone string, serial uint32) (<-chan []dns.RR, erro
|
||||||
|
|
||||||
s.Port = int(p.Port)
|
s.Port = int(p.Port)
|
||||||
|
|
||||||
s.Key = strings.Join(append(svcBase, strings.ToLower("_"+string(p.Protocol)), strings.ToLower("_"+string(p.Name))), "/")
|
s.Key = strings.Join(append(svcBase, strings.ToLower("_"+p.Protocol), strings.ToLower("_"+p.Name)), "/")
|
||||||
ch <- []dns.RR{s.NewSRV(msg.Domain(s.Key), srvWeight)}
|
ch <- []dns.RR{s.NewSRV(msg.Domain(s.Key), srvWeight)}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,7 +199,7 @@ func (w *weightedRR) topAddressIndex(address []dns.RR) int {
|
||||||
for _, wa := range weightedAddr {
|
for _, wa := range weightedAddr {
|
||||||
psum += uint(wa.weight)
|
psum += uint(wa.weight)
|
||||||
if v < psum {
|
if v < psum {
|
||||||
return int(wa.index)
|
return wa.index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ func TestNsidCache(t *testing.T) {
|
||||||
if err != tc.expectedErr {
|
if err != tc.expectedErr {
|
||||||
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
|
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
|
||||||
}
|
}
|
||||||
if code != int(tc.expectedCode) {
|
if code != tc.expectedCode {
|
||||||
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
||||||
}
|
}
|
||||||
if tc.expectedReply != "" {
|
if tc.expectedReply != "" {
|
||||||
|
|
|
@ -26,7 +26,7 @@ func TestMinimalTTL(t *testing.T) {
|
||||||
t.Fatalf("Expected type to be response.NoData, got %s", mt)
|
t.Fatalf("Expected type to be response.NoData, got %s", mt)
|
||||||
}
|
}
|
||||||
dur := MinimalTTL(m, mt) // minTTL on msg is 3600 (neg. ttl on SOA)
|
dur := MinimalTTL(m, mt) // minTTL on msg is 3600 (neg. ttl on SOA)
|
||||||
if dur != time.Duration(1800*time.Second) {
|
if dur != 1800*time.Second {
|
||||||
t.Fatalf("Expected minttl duration to be %d, got %d", 1800, dur)
|
t.Fatalf("Expected minttl duration to be %d, got %d", 1800, dur)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ func TestMinimalTTL(t *testing.T) {
|
||||||
t.Fatalf("Expected type to be response.NameError, got %s", mt)
|
t.Fatalf("Expected type to be response.NameError, got %s", mt)
|
||||||
}
|
}
|
||||||
dur = MinimalTTL(m, mt) // minTTL on msg is 3600 (neg. ttl on SOA)
|
dur = MinimalTTL(m, mt) // minTTL on msg is 3600 (neg. ttl on SOA)
|
||||||
if dur != time.Duration(1800*time.Second) {
|
if dur != 1800*time.Second {
|
||||||
t.Fatalf("Expected minttl duration to be %d, got %d", 1800, dur)
|
t.Fatalf("Expected minttl duration to be %d, got %d", 1800, dur)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ func ipToWire(family int, ipAddr string) ([]byte, error) {
|
||||||
// uint16ToWire writes unit16 to wire/binary format
|
// uint16ToWire writes unit16 to wire/binary format
|
||||||
func uint16ToWire(data uint16) []byte {
|
func uint16ToWire(data uint16) []byte {
|
||||||
buf := make([]byte, 2)
|
buf := make([]byte, 2)
|
||||||
binary.BigEndian.PutUint16(buf, uint16(data))
|
binary.BigEndian.PutUint16(buf, data)
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -231,7 +231,7 @@ func TestRoute53(t *testing.T) {
|
||||||
if err != tc.expectedErr {
|
if err != tc.expectedErr {
|
||||||
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
|
t.Fatalf("Test %d: Expected error %v, but got %v", ti, tc.expectedErr, err)
|
||||||
}
|
}
|
||||||
if code != int(tc.wantRetCode) {
|
if code != tc.wantRetCode {
|
||||||
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
|
t.Fatalf("Test %d: Expected returned status code %s, but got %s", ti, dns.RcodeToString[tc.wantRetCode], dns.RcodeToString[code])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ func TestWhoami(t *testing.T) {
|
||||||
if err != tc.expectedErr {
|
if err != tc.expectedErr {
|
||||||
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
|
t.Errorf("Test %d: Expected error %v, but got %v", i, tc.expectedErr, err)
|
||||||
}
|
}
|
||||||
if code != int(tc.expectedCode) {
|
if code != tc.expectedCode {
|
||||||
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
t.Errorf("Test %d: Expected status code %d, but got %d", i, tc.expectedCode, code)
|
||||||
}
|
}
|
||||||
if len(tc.expectedReply) != 0 {
|
if len(tc.expectedReply) != 0 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue