@@ -52,12 +52,11 @@ const (
52
52
flagUsername = "username"
53
53
flagPassword = "password"
54
54
flagTimeout = "request-timeout"
55
- flagHTTPCacheDir = "cache-dir"
55
+ flagCacheDir = "cache-dir"
56
56
)
57
57
58
58
var (
59
- defaultCacheDir = filepath .Join (homedir .HomeDir (), ".kube" , "http-cache" )
60
- defaultDiscoveryCacheParentDir = filepath .Join (homedir .HomeDir (), ".kube" , "cache" , "discovery" )
59
+ defaultCacheDir = filepath .Join (homedir .HomeDir (), ".kube" , "cache" )
61
60
)
62
61
63
62
// RESTClientGetter is an interface that the ConfigFlags describe to provide an easier way to mock for commands
@@ -227,19 +226,15 @@ func (f *ConfigFlags) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, e
227
226
// double it just so we don't end up here again for a while. This config is only used for discovery.
228
227
config .Burst = 100
229
228
230
- httpCacheDir , discoveryCacheParentDir := defaultCacheDir , defaultDiscoveryCacheParentDir
229
+ cacheDir := defaultCacheDir
231
230
232
231
// retrieve a user-provided value for the "cache-dir"
233
232
// override httpCacheDir and discoveryCacheDir if user-value is given.
234
233
if f .CacheDir != nil {
235
- httpCacheDir = * f .CacheDir
236
- if len (httpCacheDir ) > 0 {
237
- // override discoveryCacheDir default value so that server resources and http-cache data are stored in the same location
238
- discoveryCacheParentDir = filepath .Join (filepath .Dir (httpCacheDir ), "cache" , "discovery" )
239
- }
234
+ cacheDir = * f .CacheDir
240
235
}
241
-
242
- discoveryCacheDir := computeDiscoverCacheDir (discoveryCacheParentDir , config .Host )
236
+ httpCacheDir := filepath . Join ( cacheDir , "http" )
237
+ discoveryCacheDir := computeDiscoverCacheDir (filepath . Join ( cacheDir , "discovery" ) , config .Host )
243
238
244
239
return diskcached .NewCachedDiscoveryClientForConfig (config , discoveryCacheDir , httpCacheDir , time .Duration (10 * time .Minute ))
245
240
}
@@ -262,7 +257,7 @@ func (f *ConfigFlags) AddFlags(flags *pflag.FlagSet) {
262
257
flags .StringVar (f .KubeConfig , "kubeconfig" , * f .KubeConfig , "Path to the kubeconfig file to use for CLI requests." )
263
258
}
264
259
if f .CacheDir != nil {
265
- flags .StringVar (f .CacheDir , flagHTTPCacheDir , * f .CacheDir , "Default HTTP cache directory" )
260
+ flags .StringVar (f .CacheDir , flagCacheDir , * f .CacheDir , "Default cache directory" )
266
261
}
267
262
268
263
// add config options
0 commit comments