diff --git a/staging/src/k8s.io/apiserver/pkg/endpoints/installer.go b/staging/src/k8s.io/apiserver/pkg/endpoints/installer.go index 38926a253b7..94495d886aa 100644 --- a/staging/src/k8s.io/apiserver/pkg/endpoints/installer.go +++ b/staging/src/k8s.io/apiserver/pkg/endpoints/installer.go @@ -545,9 +545,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag reqScope.MetaGroupVersion = *a.group.MetaGroupVersion } for _, action := range actions { - versionedObject := storageMeta.ProducesObject(action.Verb) - if versionedObject == nil { - versionedObject = defaultVersionedObject + producedObject := storageMeta.ProducesObject(action.Verb) + if producedObject == nil { + producedObject = defaultVersionedObject } reqScope.Namer = action.Namer @@ -617,8 +617,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")). Operation("read"+namespaced+kind+strings.Title(subresource)+operationSuffix). Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...). - Returns(http.StatusOK, "OK", versionedObject). - Writes(versionedObject) + Returns(http.StatusOK, "OK", producedObject). + Writes(producedObject) if isGetterWithOptions { if err := addObjectParams(ws, route, versionedGetOptions); err != nil { return nil, err @@ -677,9 +677,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")). Operation("replace"+namespaced+kind+strings.Title(subresource)+operationSuffix). Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...). - Returns(http.StatusOK, "OK", versionedObject). - Reads(versionedObject). - Writes(versionedObject) + Returns(http.StatusOK, "OK", producedObject). + Reads(defaultVersionedObject). + Writes(producedObject) addParams(route, action.Params) routes = append(routes, route) case "PATCH": // Partially update a resource @@ -694,9 +694,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag Consumes(string(types.JSONPatchType), string(types.MergePatchType), string(types.StrategicMergePatchType)). Operation("patch"+namespaced+kind+strings.Title(subresource)+operationSuffix). Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...). - Returns(http.StatusOK, "OK", versionedObject). + Returns(http.StatusOK, "OK", producedObject). Reads(metav1.Patch{}). - Writes(versionedObject) + Writes(producedObject) addParams(route, action.Params) routes = append(routes, route) case "POST": // Create a resource. @@ -717,9 +717,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")). Operation("create"+namespaced+kind+strings.Title(subresource)+operationSuffix). Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...). - Returns(http.StatusOK, "OK", versionedObject). - Reads(versionedObject). - Writes(versionedObject) + Returns(http.StatusOK, "OK", producedObject). + Reads(defaultVersionedObject). + Writes(producedObject) addParams(route, action.Params) routes = append(routes, route) case "DELETE": // Delete a resource. @@ -814,6 +814,10 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag routes = append(routes, buildProxyRoute(ws, "OPTIONS", a.prefix, action.Path, kind, resource, subresource, namespaced, requestScope, hasSubresource, action.Params, proxyHandler, operationSuffix)) case "CONNECT": for _, method := range connecter.ConnectMethods() { + connectProducedObject := storageMeta.ProducesObject(method) + if connectProducedObject == nil { + connectProducedObject = "string" + } doc := "connect " + method + " requests to " + kind if hasSubresource { doc = "connect " + method + " requests to " + subresource + " of " + kind @@ -825,7 +829,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag Operation("connect" + strings.Title(strings.ToLower(method)) + namespaced + kind + strings.Title(subresource) + operationSuffix). Produces("*/*"). Consumes("*/*"). - Writes("string") + Writes(connectProducedObject) if versionedConnectOptions != nil { if err := addObjectParams(ws, route, versionedConnectOptions); err != nil { return nil, err