Add a method for getting supported resources on a server

This commit is contained in:
Brendan Burns
2015-10-12 14:23:35 -07:00
parent b9c7cf43b2
commit 5afbf578b0
3 changed files with 173 additions and 0 deletions

View File

@@ -60,6 +60,8 @@ type Fake struct {
WatchReactionChain []WatchReactor
// ProxyReactionChain is the list of proxy reactors that will be attempted for every request in the order they are tried
ProxyReactionChain []ProxyReactor
Resources []api.APIResourceList
}
// Reactor is an interface to allow the composition of reaction functions.
@@ -272,6 +274,35 @@ func (c *Fake) Extensions() client.ExtensionsInterface {
return &FakeExperimental{c}
}
func (c *Fake) SupportedResources() (map[string]*api.APIResourceList, error) {
action := ActionImpl{
Verb: "get",
Resource: "resources",
}
c.Invokes(action, nil)
result := map[string]*api.APIResourceList{}
for _, resource := range c.Resources {
result[resource.GroupVersion] = &api.APIResourceList{
APIResources: resource.APIResources,
}
}
return result, nil
}
func (c *Fake) SupportedResourcesForGroupVersion(version string) (*api.APIResourceList, error) {
action := ActionImpl{
Verb: "get",
Resource: "resource",
}
c.Invokes(action, nil)
for _, resource := range c.Resources {
if resource.GroupVersion == version {
return &resource, nil
}
}
return nil, nil
}
func (c *Fake) ServerVersion() (*version.Info, error) {
action := ActionImpl{}
action.Verb = "get"