mirror of
https://github.com/coredns/coredns.git
synced 2025-11-13 23:42:40 -05:00
plugin/rewrite: tweak parse error messaging, add tests (#1737)
* tweak parse error messaging, add tests * looser err msg checking
This commit is contained in:
committed by
Miek Gieben
parent
9e8893a0b5
commit
5e06687ee5
@@ -91,7 +91,7 @@ func newRule(args ...string) (Rule, error) {
|
||||
mode := Stop
|
||||
switch arg0 {
|
||||
case Continue:
|
||||
mode = arg0
|
||||
mode = Continue
|
||||
ruleType = strings.ToLower(args[1])
|
||||
expectNumArgs = len(args) - 1
|
||||
startArg = 2
|
||||
@@ -106,9 +106,14 @@ func newRule(args ...string) (Rule, error) {
|
||||
startArg = 1
|
||||
}
|
||||
|
||||
if ruleType == "answer" {
|
||||
return nil, fmt.Errorf("response rewrites must begin with a name rule")
|
||||
}
|
||||
|
||||
if ruleType != "edns0" && ruleType != "name" && expectNumArgs != 3 {
|
||||
return nil, fmt.Errorf("%s rules must have exactly two arguments", ruleType)
|
||||
}
|
||||
|
||||
switch ruleType {
|
||||
case "name":
|
||||
return newNameRule(mode, args[startArg:]...)
|
||||
|
||||
Reference in New Issue
Block a user