Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ linters:
# https://staticcheck.dev/docs/configuration/options/#checks
checks:
- all
- -QF*
- -QF1001 # apply De Morgan's law
- -QF1008 # remove embedded field from selector
- -SA3000 # false positive for Go 1.15+. See https://github.com/golang/go/issues/34129
- -ST1000
- -ST1001 # duplicates revive.dot-imports
Expand Down
5 changes: 3 additions & 2 deletions pkg/guestagent/kubernetesservice/kubernetesservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,10 @@ func (s *ServiceWatcher) GetPorts() []Entry {
}

var port int32
if service.Spec.Type == corev1.ServiceTypeNodePort {
switch service.Spec.Type {
case corev1.ServiceTypeNodePort:
port = portEntry.NodePort
} else if service.Spec.Type == corev1.ServiceTypeLoadBalancer {
case corev1.ServiceTypeLoadBalancer:
port = portEntry.Port
}

Expand Down
6 changes: 1 addition & 5 deletions pkg/hostagent/dns/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ func newStaticClientConfig(ips []string) (*dns.ClientConfig, error) {

func (h *Handler) lookupCnameToHost(cname string) string {
seen := make(map[string]bool)
for {
// break cyclic definition
if seen[cname] {
break
}
for !seen[cname] { // break cyclic definition
if _, ok := h.cnameToHost[cname]; ok {
seen[cname] = true
cname = h.cnameToHost[cname]
Expand Down
20 changes: 20 additions & 0 deletions pkg/hostagent/dns/dns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ func TestDNSRecords(t *testing.T) {
"host.lima.internal": "10.10.0.34",
"my.host": "host.lima.internal",
"default": "my.domain.com",
"cycle1.example.com": "cycle2.example.com",
"cycle2.example.com": "cycle1.example.com",
"self.example.com": "self.example.com",
},
}

Expand Down Expand Up @@ -120,6 +123,23 @@ func TestDNSRecords(t *testing.T) {
assert.Assert(t, regexMatch(dnsResult.String(), tc.expectedCNAME))
}
})

t.Run("test cyclic CNAME records", func(t *testing.T) {
tests := []struct {
testDomain string
expectedCNAME string
}{
{testDomain: "cycle1.example.com", expectedCNAME: `cycle1.example.com.`},
{testDomain: "self.example.com", expectedCNAME: `self.example.com.`},
}

for _, tc := range tests {
req := new(dns.Msg)
req.SetQuestion(dns.Fqdn(tc.testDomain), dns.TypeCNAME)
h.ServeDNS(w, req)
assert.Assert(t, regexMatch(dnsResult.String(), tc.expectedCNAME))
}
})
}

type TestResponseWriter struct{}
Expand Down
Loading