plugin/kubernetes: correctly set NODATA for ns (#1229)

* plugin/kubernetes: Add GetNamespaceByName

A bare or wildcard query for just the namespace should return NODATA,
not NXDOMAIN, otherwise we deny the entirety of the names under the
namespace.

Add test to check for this in pod verified mode.

* Review

More comments and move namespace code to namespace.go
This commit is contained in:
Miek Gieben
2017-11-13 21:51:51 +00:00
committed by GitHub
parent 9018451dd3
commit c37bf56b1e
8 changed files with 101 additions and 10 deletions

View File

@@ -476,3 +476,14 @@ func (APIConnServeTest) GetNodeByName(name string) (*api.Node, error) {
},
}, nil
}
func (APIConnServeTest) GetNamespaceByName(name string) (*api.Namespace, error) {
if name == "pod-nons" { // hanlder_pod_verified_test.go uses this for non-existent namespace.
return &api.Namespace{}, nil
}
return &api.Namespace{
ObjectMeta: meta.ObjectMeta{
Name: name,
},
}, nil
}