Upgrade k8s package verison (#5358)
* upgrade k8s package version Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> * Script upgrade and code formatting. Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>
This commit is contained in:
79
vendor/k8s.io/apiserver/pkg/endpoints/installer.go
generated
vendored
79
vendor/k8s.io/apiserver/pkg/endpoints/installer.go
generated
vendored
@@ -19,14 +19,13 @@ package endpoints
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
gpath "path"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
restful "github.com/emicklei/go-restful"
|
||||
restful "github.com/emicklei/go-restful/v3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/conversion"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -217,7 +216,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
isSubresource := len(subresource) > 0
|
||||
|
||||
// If there is a subresource, namespace scoping is defined by the parent resource
|
||||
namespaceScoped := true
|
||||
var namespaceScoped bool
|
||||
if isSubresource {
|
||||
parentStorage, ok := a.group.Storage[resource]
|
||||
if !ok {
|
||||
@@ -251,6 +250,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
connecter, isConnecter := storage.(rest.Connecter)
|
||||
storageMeta, isMetadata := storage.(rest.StorageMetadata)
|
||||
storageVersionProvider, isStorageVersionProvider := storage.(rest.StorageVersionProvider)
|
||||
gvAcceptor, _ := storage.(rest.GroupVersionAcceptor)
|
||||
if !isMetadata {
|
||||
storageMeta = defaultStorageMetadata{}
|
||||
}
|
||||
@@ -427,10 +427,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
apiResource.Namespaced = false
|
||||
apiResource.Kind = resourceKind
|
||||
namer := handlers.ContextBasedNaming{
|
||||
SelfLinker: a.group.Linker,
|
||||
ClusterScoped: true,
|
||||
SelfLinkPathPrefix: gpath.Join(a.prefix, resource) + "/",
|
||||
SelfLinkPathSuffix: suffix,
|
||||
Namer: a.group.Namer,
|
||||
ClusterScoped: true,
|
||||
}
|
||||
|
||||
// Handler for standard REST verbs (GET, PUT, POST and DELETE).
|
||||
@@ -476,10 +474,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
apiResource.Namespaced = true
|
||||
apiResource.Kind = resourceKind
|
||||
namer := handlers.ContextBasedNaming{
|
||||
SelfLinker: a.group.Linker,
|
||||
ClusterScoped: false,
|
||||
SelfLinkPathPrefix: gpath.Join(a.prefix, namespaceParamName) + "/",
|
||||
SelfLinkPathSuffix: itemPathSuffix,
|
||||
Namer: a.group.Namer,
|
||||
ClusterScoped: false,
|
||||
}
|
||||
|
||||
actions = appendIf(actions, action{"LIST", resourcePath, resourceParams, namer, false}, isLister)
|
||||
@@ -540,6 +536,11 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
}
|
||||
}
|
||||
|
||||
var disabledParams []string
|
||||
if !utilfeature.DefaultFeatureGate.Enabled(features.ServerSideFieldValidation) {
|
||||
disabledParams = []string{"fieldValidation"}
|
||||
}
|
||||
|
||||
// Create Routes for the actions.
|
||||
// TODO: Add status documentation using Returns()
|
||||
// Errors (see api/errors/errors.go as well as go-restful router):
|
||||
@@ -587,6 +588,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Subresource: subresource,
|
||||
Kind: fqKindToRegister,
|
||||
|
||||
AcceptsGroupVersionDelegate: gvAcceptor,
|
||||
|
||||
HubGroupVersion: schema.GroupVersion{Group: fqKindToRegister.Group, Version: runtime.APIVersionInternal},
|
||||
|
||||
MetaGroupVersion: metav1.SchemeGroupVersion,
|
||||
@@ -604,7 +607,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
a.group.Creater,
|
||||
fqKindToRegister,
|
||||
reqScope.HubGroupVersion,
|
||||
isSubresource,
|
||||
subresource,
|
||||
resetFields,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -666,8 +669,6 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
|
||||
// accumulate endpoint-level warnings
|
||||
var (
|
||||
enableWarningHeaders = utilfeature.DefaultFeatureGate.Enabled(features.WarningHeaders)
|
||||
|
||||
warnings []string
|
||||
deprecated bool
|
||||
removedRelease string
|
||||
@@ -699,9 +700,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
} else {
|
||||
handler = metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, handler)
|
||||
}
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
|
||||
doc := "read the specified " + kind
|
||||
if isSubresource {
|
||||
@@ -727,9 +726,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
doc = "list " + subresource + " of objects of kind " + kind
|
||||
}
|
||||
handler := metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, restfulListResource(lister, watcher, reqScope, false, a.minRequestTimeout))
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
route := ws.GET(action.Path).To(handler).
|
||||
Doc(doc).
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
@@ -762,9 +759,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
doc = "replace " + subresource + " of the specified " + kind
|
||||
}
|
||||
handler := metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, restfulUpdateResource(updater, reqScope, admit))
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
route := ws.PUT(action.Path).To(handler).
|
||||
Doc(doc).
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
@@ -776,7 +771,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Returns(http.StatusCreated, "Created", producedObject).
|
||||
Reads(defaultVersionedObject).
|
||||
Writes(producedObject)
|
||||
if err := AddObjectParams(ws, route, versionedUpdateOptions); err != nil {
|
||||
if err := AddObjectParams(ws, route, versionedUpdateOptions, disabledParams...); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
addParams(route, action.Params)
|
||||
@@ -795,9 +790,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
supportedTypes = append(supportedTypes, string(types.ApplyPatchType))
|
||||
}
|
||||
handler := metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, restfulPatchResource(patcher, reqScope, admit, supportedTypes))
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
route := ws.PATCH(action.Path).To(handler).
|
||||
Doc(doc).
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
@@ -805,9 +798,11 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Operation("patch"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||
Returns(http.StatusOK, "OK", producedObject).
|
||||
// Patch can return 201 when a server side apply is requested
|
||||
Returns(http.StatusCreated, "Created", producedObject).
|
||||
Reads(metav1.Patch{}).
|
||||
Writes(producedObject)
|
||||
if err := AddObjectParams(ws, route, versionedPatchOptions); err != nil {
|
||||
if err := AddObjectParams(ws, route, versionedPatchOptions, disabledParams...); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
addParams(route, action.Params)
|
||||
@@ -820,9 +815,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
handler = restfulCreateResource(creater, reqScope, admit)
|
||||
}
|
||||
handler = metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, handler)
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
article := GetArticleForNoun(kind, " ")
|
||||
doc := "create" + article + kind
|
||||
if isSubresource {
|
||||
@@ -840,7 +833,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
Returns(http.StatusAccepted, "Accepted", producedObject).
|
||||
Reads(defaultVersionedObject).
|
||||
Writes(producedObject)
|
||||
if err := AddObjectParams(ws, route, versionedCreateOptions); err != nil {
|
||||
if err := AddObjectParams(ws, route, versionedCreateOptions, disabledParams...); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
addParams(route, action.Params)
|
||||
@@ -856,9 +849,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
deleteReturnType = producedObject
|
||||
}
|
||||
handler := metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, restfulDeleteResource(gracefulDeleter, isGracefulDeleter, reqScope, admit))
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
route := ws.DELETE(action.Path).To(handler).
|
||||
Doc(doc).
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
@@ -882,9 +873,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
doc = "delete collection of " + subresource + " of a " + kind
|
||||
}
|
||||
handler := metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, restfulDeleteCollection(collectionDeleter, isCollectionDeleter, reqScope, admit))
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
route := ws.DELETE(action.Path).To(handler).
|
||||
Doc(doc).
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
@@ -912,9 +901,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
}
|
||||
doc += ". deprecated: use the 'watch' parameter with a list operation instead, filtered to a single item with the 'fieldSelector' parameter."
|
||||
handler := metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, restfulListResource(lister, watcher, reqScope, true, a.minRequestTimeout))
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
route := ws.GET(action.Path).To(handler).
|
||||
Doc(doc).
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
@@ -935,9 +922,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
}
|
||||
doc += ". deprecated: use the 'watch' parameter with a list operation instead."
|
||||
handler := metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, restfulListResource(lister, watcher, reqScope, true, a.minRequestTimeout))
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
route := ws.GET(action.Path).To(handler).
|
||||
Doc(doc).
|
||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||
@@ -961,9 +946,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
||||
doc = "connect " + method + " requests to " + subresource + " of " + kind
|
||||
}
|
||||
handler := metrics.InstrumentRouteFunc(action.Verb, group, version, resource, subresource, requestScope, metrics.APIServerComponent, deprecated, removedRelease, restfulConnectResource(connecter, reqScope, admit, path, isSubresource))
|
||||
if enableWarningHeaders {
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
}
|
||||
handler = utilwarning.AddWarningsHandler(handler, warnings)
|
||||
route := ws.Method(method).Path(action.Path).
|
||||
To(handler).
|
||||
Doc(doc).
|
||||
@@ -1067,7 +1050,7 @@ func AddObjectParams(ws *restful.WebService, route *restful.RouteBuilder, obj in
|
||||
}
|
||||
switch sf.Type.Kind() {
|
||||
case reflect.Interface, reflect.Struct:
|
||||
case reflect.Ptr:
|
||||
case reflect.Pointer:
|
||||
// TODO: This is a hack to let metav1.Time through. This needs to be fixed in a more generic way eventually. bug #36191
|
||||
if (sf.Type.Elem().Kind() == reflect.Interface || sf.Type.Elem().Kind() == reflect.Struct) && strings.TrimPrefix(sf.Type.String(), "*") != "metav1.Time" {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user