mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-12-02 22:33:52 +00:00
remove metrics client factory method
This commit is contained in:
@@ -27,7 +27,6 @@ import (
|
||||
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
|
||||
oldclient "k8s.io/kubernetes/pkg/client/unversioned"
|
||||
"k8s.io/kubernetes/pkg/version"
|
||||
metricsclientset "k8s.io/metrics/pkg/client/clientset_generated/clientset"
|
||||
)
|
||||
|
||||
func NewClientCache(loader clientcmd.ClientConfig, discoveryClientFactory DiscoveryClientFactory) *ClientCache {
|
||||
@@ -59,7 +58,6 @@ type ClientCache struct {
|
||||
discoveryClient discovery.DiscoveryInterface
|
||||
|
||||
kubernetesClientCache kubernetesClientCache
|
||||
metricsClientCache metricsClientCache
|
||||
}
|
||||
|
||||
// kubernetesClientCache creates a new kubernetes.Clientset one time
|
||||
@@ -73,17 +71,6 @@ type kubernetesClientCache struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// metricsClientCache creates a new metricsclientset.Clientset one time
|
||||
// and then returns the result for all future requests
|
||||
type metricsClientCache struct {
|
||||
// once makes sure the client is only initialized once
|
||||
once sync.Once
|
||||
// client is the cached client value
|
||||
client *metricsclientset.Clientset
|
||||
// err is the cached error value
|
||||
err error
|
||||
}
|
||||
|
||||
// KubernetesClientSetForVersion returns a new kubernetes.Clientset. It will cache the value
|
||||
// the first time it is called and return the cached value on subsequent calls.
|
||||
// If an error is encountered the first time KubernetesClientSetForVersion is called,
|
||||
@@ -100,22 +87,6 @@ func (c *ClientCache) KubernetesClientSetForVersion(requiredVersion *schema.Grou
|
||||
return c.kubernetesClientCache.client, c.kubernetesClientCache.err
|
||||
}
|
||||
|
||||
// MetricsClientSetForVersion returns a new kubernetes.Clientset. It will cache the value
|
||||
// the first time it is called and return the cached value on subsequent calls.
|
||||
// If an error is encountered the first time MetircsClientSetForVersion is called,
|
||||
// the error will be cached.
|
||||
func (c *ClientCache) MetricsClientSetForVersion(requiredVersion *schema.GroupVersion) (*metricsclientset.Clientset, error) {
|
||||
c.metricsClientCache.once.Do(func() {
|
||||
config, err := c.ClientConfigForVersion(requiredVersion)
|
||||
if err != nil {
|
||||
c.kubernetesClientCache.err = err
|
||||
return
|
||||
}
|
||||
c.metricsClientCache.client, c.metricsClientCache.err = metricsclientset.NewForConfig(config)
|
||||
})
|
||||
return c.metricsClientCache.client, c.metricsClientCache.err
|
||||
}
|
||||
|
||||
// also looks up the discovery client. We can't do this during init because the flags won't have been set
|
||||
// because this is constructed pre-command execution before the command tree is
|
||||
// even set up. Requires the lock to already be acquired
|
||||
|
||||
Reference in New Issue
Block a user