Unittest for #9762
Started looking at refactoring of the kubectl Factory, which caused me to experience all 5 stages of grief. There are some options for improving, but it probably warrants a proposal with some discussion/ feedback. In the meantime this tests `NegotiateVersion` in isolation.
This commit is contained in:
@@ -36,6 +36,7 @@ type clientCache struct {
|
||||
clients map[string]*client.Client
|
||||
configs map[string]*client.Config
|
||||
defaultConfig *client.Config
|
||||
defaultClient *client.Client
|
||||
matchVersion bool
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, er
|
||||
}
|
||||
c.defaultConfig = config
|
||||
if c.matchVersion {
|
||||
if err := client.MatchesServerVersion(config); err != nil {
|
||||
if err := client.MatchesServerVersion(c.defaultClient, config); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
@@ -58,7 +59,7 @@ func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, er
|
||||
}
|
||||
// TODO: have a better config copy method
|
||||
config := *c.defaultConfig
|
||||
negotiatedVersion, err := client.NegotiateVersion(&config, version)
|
||||
negotiatedVersion, err := client.NegotiateVersion(c.defaultClient, &config, version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
Reference in New Issue
Block a user