kubernetes: Improve namespace usage (#4767)
* Use GetByKey instead of List in GetNamespaceByName. * Add ToNamespace to reduce memory for namespace cache. Signed-off-by: Mat Lowery <mlowery@ebay.com>
This commit is contained in:
parent
8ff7c4b834
commit
9d5b8cd13d
9 changed files with 100 additions and 47 deletions
|
@ -782,16 +782,14 @@ func (APIConnServeTest) GetNodeByName(ctx context.Context, name string) (*api.No
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (APIConnServeTest) GetNamespaceByName(name string) (*api.Namespace, error) {
|
||||
func (APIConnServeTest) GetNamespaceByName(name string) (*object.Namespace, error) {
|
||||
if name == "pod-nons" { // handler_pod_verified_test.go uses this for non-existent namespace.
|
||||
return &api.Namespace{}, nil
|
||||
return nil, fmt.Errorf("namespace not found")
|
||||
}
|
||||
if name == "nsnoexist" {
|
||||
return nil, fmt.Errorf("namespace not found")
|
||||
}
|
||||
return &api.Namespace{
|
||||
ObjectMeta: meta.ObjectMeta{
|
||||
Name: name,
|
||||
},
|
||||
return &object.Namespace{
|
||||
Name: name,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue