mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
Revert "Merge pull request #47353 from apelisse/http-cache"
This reverts commitfc89743dca, reversing changes made to29ab38e898.
This commit is contained in:
@@ -439,7 +439,13 @@ func (f *ring1Factory) SwaggerSchema(gvk schema.GroupVersionKind) (*swagger.ApiD
|
||||
}
|
||||
|
||||
// OpenAPISchema returns metadata and structural information about Kubernetes object definitions.
|
||||
func (f *ring1Factory) OpenAPISchema() (openapi.Resources, error) {
|
||||
// Will try to cache the data to a local file. Cache is written and read from a
|
||||
// file created with ioutil.TempFile and obeys the expiration semantics of that file.
|
||||
// The cache location is a function of the client and server versions so that the open API
|
||||
// schema will be cached separately for different client / server combinations.
|
||||
// Note, the cache will not be invalidated if the server changes its open API schema without
|
||||
// changing the server version.
|
||||
func (f *ring1Factory) OpenAPISchema(cacheDir string) (openapi.Resources, error) {
|
||||
discovery, err := f.clientAccessFactory.DiscoveryClient()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -447,8 +453,23 @@ func (f *ring1Factory) OpenAPISchema() (openapi.Resources, error) {
|
||||
|
||||
// Lazily initialize the OpenAPIGetter once
|
||||
f.openAPIGetter.once.Do(func() {
|
||||
// Get the server version for caching the openapi spec
|
||||
versionString := ""
|
||||
version, err := discovery.ServerVersion()
|
||||
if err != nil {
|
||||
// Cache the result under the server version
|
||||
versionString = version.String()
|
||||
}
|
||||
|
||||
// Get the cache directory for caching the openapi spec
|
||||
cacheDir, err = substituteUserHome(cacheDir)
|
||||
if err != nil {
|
||||
// Don't cache the result if we couldn't substitute the home directory
|
||||
cacheDir = ""
|
||||
}
|
||||
|
||||
// Create the caching OpenAPIGetter
|
||||
f.openAPIGetter.getter = openapi.NewOpenAPIGetter(discovery)
|
||||
f.openAPIGetter.getter = openapi.NewOpenAPIGetter(cacheDir, versionString, discovery)
|
||||
})
|
||||
|
||||
// Delegate to the OpenAPIGetter
|
||||
|
||||
Reference in New Issue
Block a user