parent
c3705ec68c
commit
b46b9880bd
20 changed files with 597 additions and 642 deletions
|
@ -5,13 +5,11 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/coredns/coredns/core/dnsserver"
|
||||
"github.com/coredns/coredns/middleware"
|
||||
"github.com/coredns/coredns/middleware/kubernetes/autopath"
|
||||
"github.com/coredns/coredns/middleware/pkg/dnsutil"
|
||||
"github.com/coredns/coredns/middleware/proxy"
|
||||
"github.com/miekg/dns"
|
||||
|
@ -196,47 +194,6 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
|
|||
continue
|
||||
}
|
||||
return nil, fmt.Errorf("incorrect number of arguments for federation, got %v, expected 2", len(args))
|
||||
case "autopath": // name zone
|
||||
args := c.RemainingArgs()
|
||||
k8s.autoPath = &autopath.AutoPath{
|
||||
NDots: defautNdots,
|
||||
HostSearchPath: []string{},
|
||||
ResolvConfFile: defaultResolvConfFile,
|
||||
OnNXDOMAIN: defaultOnNXDOMAIN,
|
||||
}
|
||||
if len(args) > 3 {
|
||||
return nil, fmt.Errorf("incorrect number of arguments for autopath, got %v, expected at most 3", len(args))
|
||||
|
||||
}
|
||||
if len(args) > 0 {
|
||||
ndots, err := strconv.Atoi(args[0])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid NDOTS argument for autopath, got '%v', expected an integer", ndots)
|
||||
}
|
||||
k8s.autoPath.NDots = ndots
|
||||
}
|
||||
if len(args) > 1 {
|
||||
switch args[1] {
|
||||
case dns.RcodeToString[dns.RcodeNameError]:
|
||||
k8s.autoPath.OnNXDOMAIN = dns.RcodeNameError
|
||||
case dns.RcodeToString[dns.RcodeSuccess]:
|
||||
k8s.autoPath.OnNXDOMAIN = dns.RcodeSuccess
|
||||
case dns.RcodeToString[dns.RcodeServerFailure]:
|
||||
k8s.autoPath.OnNXDOMAIN = dns.RcodeServerFailure
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid RESPONSE argument for autopath, got '%v', expected SERVFAIL, NOERROR, or NXDOMAIN", args[1])
|
||||
}
|
||||
}
|
||||
if len(args) > 2 {
|
||||
k8s.autoPath.ResolvConfFile = args[2]
|
||||
}
|
||||
rc, err := dns.ClientConfigFromFile(k8s.autoPath.ResolvConfFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error when parsing %v: %v", k8s.autoPath.ResolvConfFile, err)
|
||||
}
|
||||
k8s.autoPath.HostSearchPath = rc.Search
|
||||
middleware.Zones(k8s.autoPath.HostSearchPath).Normalize()
|
||||
continue
|
||||
}
|
||||
}
|
||||
return k8s, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue