mw/kubernetes: rewrite parseRequest

Stop looking at the qtype in parseRequest and make k.Namespace a map.
Fallout from this is that pkg/strings as it is not used anymore. Also
add a few helper functions to make unexposed namespaces easier to see in
the code.

Add wildcard tests to the middleware tests.
This commit is contained in:
Miek Gieben
2017-08-18 19:40:12 +01:00
parent 627687b11f
commit 118ef3dfa0
7 changed files with 128 additions and 127 deletions

View File

@@ -62,13 +62,9 @@ func setup(c *caddy.Controller) error {
}
func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
k8s := &Kubernetes{
ResyncPeriod: defaultResyncPeriod,
interfaceAddrsFunc: localPodIP,
PodMode: PodModeDisabled,
Proxy: proxy.Proxy{},
autoPathSearch: searchFromResolvConf(),
}
k8s := New([]string{""})
k8s.interfaceAddrsFunc = localPodIP
k8s.autoPathSearch = searchFromResolvConf()
for c.Next() {
zones := c.RemainingArgs()
@@ -115,7 +111,9 @@ func kubernetesParse(c *caddy.Controller) (*Kubernetes, error) {
case "namespaces":
args := c.RemainingArgs()
if len(args) > 0 {
k8s.Namespaces = append(k8s.Namespaces, args...)
for _, a := range args {
k8s.Namespaces[a] = true
}
continue
}
return nil, c.ArgErr()