aboutsummaryrefslogtreecommitdiff
path: root/core/setup/kubernetes.go
diff options
context:
space:
mode:
authorGravatar Michael Richmond <mrichmon@users.noreply.github.com> 2016-07-22 16:07:27 -0700
committerGravatar GitHub <noreply@github.com> 2016-07-22 16:07:27 -0700
commit4a3b57d81b6c0f401fab7492e40307ac7a0c4c97 (patch)
tree51ee32285d9585127d1211411fe94454a70b9867 /core/setup/kubernetes.go
parent3ba86f24211639a985d37f0c708e0a6dd30c862f (diff)
downloadcoredns-4a3b57d81b6c0f401fab7492e40307ac7a0c4c97.tar.gz
coredns-4a3b57d81b6c0f401fab7492e40307ac7a0c4c97.tar.zst
coredns-4a3b57d81b6c0f401fab7492e40307ac7a0c4c97.zip
Adding test cases for Corefile parsing (#193)
Adding test cases for Corefile parsing. Some code refactoring to allow test reuse.
Diffstat (limited to 'core/setup/kubernetes.go')
-rw-r--r--core/setup/kubernetes.go34
1 files changed, 13 insertions, 21 deletions
diff --git a/core/setup/kubernetes.go b/core/setup/kubernetes.go
index aea9e334a..2f8b5be44 100644
--- a/core/setup/kubernetes.go
+++ b/core/setup/kubernetes.go
@@ -1,23 +1,14 @@
package setup
import (
- //"crypto/tls"
- //"crypto/x509"
"log"
- //"io/ioutil"
- //"net"
- //"net/http"
"strings"
- //"time"
"github.com/miekg/coredns/middleware"
"github.com/miekg/coredns/middleware/kubernetes"
k8sc "github.com/miekg/coredns/middleware/kubernetes/k8sclient"
"github.com/miekg/coredns/middleware/kubernetes/nametemplate"
"github.com/miekg/coredns/middleware/proxy"
- //"github.com/miekg/coredns/middleware/singleflight"
-
- "golang.org/x/net/context"
)
const (
@@ -43,19 +34,8 @@ func Kubernetes(c *Controller) (middleware.Middleware, error) {
}
func kubernetesParse(c *Controller) (kubernetes.Kubernetes, error) {
-
- /*
- * TODO: Remove unused state and simplify.
- * Inflight and Ctx might not be needed. Leaving in place until
- * we take a pass at API caching and optimizing connector to the
- * k8s API. Single flight (or limited upper-bound) for inflight
- * API calls may be desirable.
- */
-
k8s := kubernetes.Kubernetes{
Proxy: proxy.New([]string{}),
- Ctx: context.Background(),
- // Inflight: &singleflight.Group{},
}
var (
endpoints = []string{defaultK8sEndpoint}
@@ -78,7 +58,12 @@ func kubernetesParse(c *Controller) (kubernetes.Kubernetes, error) {
k8s.Zones = kubernetes.NormalizeZoneList(zones)
}
+ // TODO: clean this parsing up
+
middleware.Zones(k8s.Zones).FullyQualify()
+
+ log.Printf("[debug] c data: %v\n", c)
+
if c.NextBlock() {
// TODO(miek): 2 switches?
switch c.Val() {
@@ -89,6 +74,13 @@ func kubernetesParse(c *Controller) (kubernetes.Kubernetes, error) {
}
endpoints = args
k8s.APIConn = k8sc.NewK8sConnector(endpoints[0])
+ case "namespaces":
+ args := c.RemainingArgs()
+ if len(args) == 0 {
+ return kubernetes.Kubernetes{}, c.ArgErr()
+ }
+ namespaces = args
+ k8s.Namespaces = append(k8s.Namespaces, namespaces...)
}
for c.Next() {
switch c.Val() {
@@ -108,7 +100,7 @@ func kubernetesParse(c *Controller) (kubernetes.Kubernetes, error) {
return kubernetes.Kubernetes{}, c.ArgErr()
}
namespaces = args
- k8s.Namespaces = &namespaces
+ k8s.Namespaces = append(k8s.Namespaces, namespaces...)
}
}
}