// ClientConfigForVersion returns the correct config for a server func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, error) { if c.defaultConfig == nil { config, err := c.loader.ClientConfig() if err != nil { return nil, err } c.defaultConfig = config if c.matchVersion { if err := client.MatchesServerVersion(c.defaultClient, config); err != nil { return nil, err } } } if config, ok := c.configs[version]; ok { return config, nil } // TODO: have a better config copy method config := *c.defaultConfig negotiatedVersion, err := client.NegotiateVersion(c.defaultClient, &config, version, registered.RegisteredVersions) if err != nil { return nil, err } config.Version = negotiatedVersion client.SetKubernetesDefaults(&config) c.configs[version] = &config return &config, nil }
// ClientConfigForVersion returns the correct config for a server func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, error) { if c.defaultConfig == nil { config, err := c.loader.ClientConfig() if err != nil { return nil, err } c.defaultConfig = config if c.matchVersion { if err := client.MatchesServerVersion(config); err != nil { return nil, err } } } // TODO: remove when SetKubernetesDefaults gets added if len(version) == 0 { version = c.defaultConfig.Version } // TODO: have a better config copy method config := *c.defaultConfig // TODO: call new client.SetKubernetesDefaults method // instead of doing this config.Version = version return &config, nil }
// ClientConfigForVersion returns the correct config for a server func (c *clientCache) ClientConfigForVersion(version string) (*client.Config, error) { if c.defaultConfig == nil { config, err := c.loader.ClientConfig() if err != nil { return nil, err } c.defaultConfig = config if c.matchVersion { if err := client.MatchesServerVersion(config); err != nil { return nil, err } } } // TODO: have a better config copy method config := *c.defaultConfig client.SetKubernetesDefaults(&config) return &config, nil }