mirror of
https://github.com/coredns/coredns.git
synced 2025-10-28 16:54:15 -04:00
middleware/authpath: Fix return from k8s mw (#871)
* middleware/authpath: Fix return from k8s mw Return the correct search path from the kubernetes' AutoPath function. Based on preliminary discussion in #870 * PodWithIP can be private Fix and add docs to functions. * CR: remove the error from AutoPathFunc
This commit is contained in:
@@ -62,6 +62,8 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
|
||||
Proxy: proxy.Proxy{},
|
||||
}
|
||||
|
||||
k8s.autoPathSearch = searchFromResolvConf()
|
||||
|
||||
for c.Next() {
|
||||
if c.Val() == "kubernetes" {
|
||||
zones := c.RemainingArgs()
|
||||
@@ -202,6 +204,15 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
|
||||
return nil, errors.New("kubernetes setup called without keyword 'kubernetes' in Corefile")
|
||||
}
|
||||
|
||||
func searchFromResolvConf() []string {
|
||||
rc, err := dns.ClientConfigFromFile("/etc/resolv.conf")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
middleware.Zones(rc.Search).Normalize()
|
||||
return rc.Search
|
||||
}
|
||||
|
||||
const (
|
||||
defaultResyncPeriod = 5 * time.Minute
|
||||
defautNdots = 0
|
||||
|
||||
Reference in New Issue
Block a user