mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Merge pull request #51972 from jim-minter/producedObject
Automatic merge from submit-queue (batch tested with PRs 51067, 52319, 52803, 52961, 51972). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.. ProducesObject should only update the returned API object resource documentation This should be a no-op for Kubernetes (the only rest.Storage that specifies ProducesObject() is pod logs, on GET), but will allow issues such as openshift/origin#8345 to be resolved (where generated API documentation is currently incorrect due to the asymmetry between the object kind sent and received by the API) ```release-note NONE```
This commit is contained in:
commit
50fa5637b6
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user