Create client from API version passed in config or use default

When creating a client read the GroupVersion value passed in the
restclient.Config. If the passed GroupVersion does not match current
group or is not enabled fallback to default GroupVersion for that group.
This commit is contained in:
Maciej Szulik
2016-07-18 16:46:48 +02:00
parent 72a697a13d
commit 1e496fd8ce
10 changed files with 54 additions and 228 deletions

View File

@@ -76,12 +76,12 @@ func (c *ClientCache) ClientConfigForVersion(version *unversioned.GroupVersion)
preferredGV = &versionCopy
}
client.SetKubernetesDefaults(&config)
negotiatedVersion, err := client.NegotiateVersion(c.defaultClient, &config, preferredGV, registered.EnabledVersions())
if err != nil {
return nil, err
}
config.GroupVersion = negotiatedVersion
client.SetKubernetesDefaults(&config)
if version != nil {
c.configs[*version] = &config