mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-12-01 17:44:30 +00:00
move cached_discovery to client-go/discovery
This commit is contained in:
@@ -18,7 +18,6 @@ package util
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
@@ -32,8 +31,6 @@ import (
|
||||
"k8s.io/client-go/restmapper"
|
||||
"k8s.io/client-go/tools/clientcmd"
|
||||
"k8s.io/client-go/util/homedir"
|
||||
|
||||
"k8s.io/kubernetes/pkg/kubectl/cmd/util/transport"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -179,27 +176,8 @@ func (f *ConfigFlags) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, e
|
||||
// double it just so we don't end up here again for a while. This config is only used for discovery.
|
||||
config.Burst = 100
|
||||
|
||||
cacheDir := filepath.Join(homedir.HomeDir(), ".kube", "http-cache")
|
||||
if f.CacheDir != nil {
|
||||
cacheDir = *f.CacheDir
|
||||
}
|
||||
|
||||
if len(cacheDir) > 0 {
|
||||
wt := config.WrapTransport
|
||||
config.WrapTransport = func(rt http.RoundTripper) http.RoundTripper {
|
||||
if wt != nil {
|
||||
rt = wt(rt)
|
||||
}
|
||||
return transport.NewCacheRoundTripper(cacheDir, rt)
|
||||
}
|
||||
}
|
||||
|
||||
discoveryClient, err := discovery.NewDiscoveryClientForConfig(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cacheDir = computeDiscoverCacheDir(filepath.Join(homedir.HomeDir(), ".kube", "cache", "discovery"), config.Host)
|
||||
return NewCachedDiscoveryClient(discoveryClient, cacheDir, time.Duration(10*time.Minute)), nil
|
||||
cacheDir := computeDiscoverCacheDir(filepath.Join(homedir.HomeDir(), ".kube", "cache", "discovery"), config.Host)
|
||||
return discovery.NewCachedDiscoveryClientForConfig(config, cacheDir, time.Duration(10*time.Minute))
|
||||
}
|
||||
|
||||
// RESTMapper returns a mapper.
|
||||
|
||||
Reference in New Issue
Block a user