Skip to content

Commit

Permalink
Correctly format ipv6 resolver config for lua
Browse files Browse the repository at this point in the history
Fixes #3881
  • Loading branch information
jacksontj committed Mar 14, 2019
1 parent 2dbc1ea commit eba4a8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions internal/ingress/controller/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,14 @@ func buildResolversForLua(res interface{}, disableIpv6 interface{}) string {

r := []string{}
for _, ns := range nss {
if ing_net.IsIPV6(ns) && no6 {
continue
if ing_net.IsIPV6(ns) {
if no6 {
continue
}
r = append(r, fmt.Sprintf("\"[%v]\"", ns))
} else {
r = append(r, fmt.Sprintf("\"%v\"", ns))
}
r = append(r, fmt.Sprintf("\"%v\"", ns))
}

return strings.Join(r, ", ")
Expand Down
2 changes: 1 addition & 1 deletion internal/ingress/controller/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ func TestBuildResolversForLua(t *testing.T) {
t.Errorf("Expected '%v' but returned '%v'", expected, actual)
}

expected = "\"192.0.0.1\", \"2001:db8:1234::\""
expected = "\"192.0.0.1\", \"[2001:db8:1234::]\""
actual = buildResolversForLua(ipList, false)

if expected != actual {
Expand Down

0 comments on commit eba4a8b

Please sign in to comment.