mirror of
https://github.com/coredns/coredns.git
synced 2025-12-06 10:25:10 -05:00
plugin/template: Add parseInt template function (#5609)
* plugin/template: Add parseInt template function Signed-off-by: Erik Johansson <ejohansson@spotify.com>
This commit is contained in:
@@ -83,6 +83,20 @@ func TestSetupParse(t *testing.T) {
|
||||
}`,
|
||||
true,
|
||||
},
|
||||
{
|
||||
`template ANY ANY {
|
||||
answer "{{ notAFunction }}"
|
||||
}`,
|
||||
true,
|
||||
},
|
||||
{
|
||||
`template ANY ANY {
|
||||
answer "{{ parseInt }}"
|
||||
additional "{{ parseInt }}"
|
||||
authority "{{ parseInt }}"
|
||||
}`,
|
||||
false,
|
||||
},
|
||||
// examples
|
||||
{`template ANY ANY (?P<x>`, false},
|
||||
{
|
||||
@@ -128,6 +142,13 @@ func TestSetupParse(t *testing.T) {
|
||||
}`,
|
||||
false,
|
||||
},
|
||||
{
|
||||
`template IN A example {
|
||||
match ^ip0a(?P<b>[a-f0-9]{2})(?P<c>[a-f0-9]{2})(?P<d>[a-f0-9]{2})[.]example[.]$
|
||||
answer "{{ .Name }} 3600 IN A 10.{{ parseInt .Group.b 16 8 }}.{{ parseInt .Group.c 16 8 }}.{{ parseInt .Group.d 16 8 }}"
|
||||
}`,
|
||||
false,
|
||||
},
|
||||
{
|
||||
`template IN MX example {
|
||||
match ^ip-10-(?P<b>[0-9]*)-(?P<c>[0-9]*)-(?P<d>[0-9]*)[.]example[.]$
|
||||
|
||||
Reference in New Issue
Block a user