mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-12 21:36:24 +00:00
ProducesObject should only update the returned API object resource documentation
This commit is contained in:
parent
775f5d232d
commit
e18eeb2d63
@ -545,9 +545,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||||||
reqScope.MetaGroupVersion = *a.group.MetaGroupVersion
|
reqScope.MetaGroupVersion = *a.group.MetaGroupVersion
|
||||||
}
|
}
|
||||||
for _, action := range actions {
|
for _, action := range actions {
|
||||||
versionedObject := storageMeta.ProducesObject(action.Verb)
|
producedObject := storageMeta.ProducesObject(action.Verb)
|
||||||
if versionedObject == nil {
|
if producedObject == nil {
|
||||||
versionedObject = defaultVersionedObject
|
producedObject = defaultVersionedObject
|
||||||
}
|
}
|
||||||
reqScope.Namer = action.Namer
|
reqScope.Namer = action.Namer
|
||||||
namespaced := ""
|
namespaced := ""
|
||||||
@ -618,8 +618,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||||
Operation("read"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
Operation("read"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||||
Returns(http.StatusOK, "OK", versionedObject).
|
Returns(http.StatusOK, "OK", producedObject).
|
||||||
Writes(versionedObject)
|
Writes(producedObject)
|
||||||
if isGetterWithOptions {
|
if isGetterWithOptions {
|
||||||
if err := addObjectParams(ws, route, versionedGetOptions); err != nil {
|
if err := addObjectParams(ws, route, versionedGetOptions); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -678,9 +678,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||||
Operation("replace"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
Operation("replace"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||||
Returns(http.StatusOK, "OK", versionedObject).
|
Returns(http.StatusOK, "OK", producedObject).
|
||||||
Reads(versionedObject).
|
Reads(defaultVersionedObject).
|
||||||
Writes(versionedObject)
|
Writes(producedObject)
|
||||||
addParams(route, action.Params)
|
addParams(route, action.Params)
|
||||||
routes = append(routes, route)
|
routes = append(routes, route)
|
||||||
case "PATCH": // Partially update a resource
|
case "PATCH": // Partially update a resource
|
||||||
@ -695,9 +695,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||||||
Consumes(string(types.JSONPatchType), string(types.MergePatchType), string(types.StrategicMergePatchType)).
|
Consumes(string(types.JSONPatchType), string(types.MergePatchType), string(types.StrategicMergePatchType)).
|
||||||
Operation("patch"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
Operation("patch"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||||
Returns(http.StatusOK, "OK", versionedObject).
|
Returns(http.StatusOK, "OK", producedObject).
|
||||||
Reads(metav1.Patch{}).
|
Reads(metav1.Patch{}).
|
||||||
Writes(versionedObject)
|
Writes(producedObject)
|
||||||
addParams(route, action.Params)
|
addParams(route, action.Params)
|
||||||
routes = append(routes, route)
|
routes = append(routes, route)
|
||||||
case "POST": // Create a resource.
|
case "POST": // Create a resource.
|
||||||
@ -718,9 +718,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||||||
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
|
||||||
Operation("create"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
Operation("create"+namespaced+kind+strings.Title(subresource)+operationSuffix).
|
||||||
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
|
||||||
Returns(http.StatusOK, "OK", versionedObject).
|
Returns(http.StatusOK, "OK", producedObject).
|
||||||
Reads(versionedObject).
|
Reads(defaultVersionedObject).
|
||||||
Writes(versionedObject)
|
Writes(producedObject)
|
||||||
addParams(route, action.Params)
|
addParams(route, action.Params)
|
||||||
routes = append(routes, route)
|
routes = append(routes, route)
|
||||||
case "DELETE": // Delete a resource.
|
case "DELETE": // Delete a resource.
|
||||||
@ -815,6 +815,10 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||||||
routes = append(routes, buildProxyRoute(ws, "OPTIONS", a.prefix, action.Path, kind, resource, subresource, namespaced, namespaceScope, hasSubresource, action.Params, proxyHandler, operationSuffix))
|
routes = append(routes, buildProxyRoute(ws, "OPTIONS", a.prefix, action.Path, kind, resource, subresource, namespaced, namespaceScope, hasSubresource, action.Params, proxyHandler, operationSuffix))
|
||||||
case "CONNECT":
|
case "CONNECT":
|
||||||
for _, method := range connecter.ConnectMethods() {
|
for _, method := range connecter.ConnectMethods() {
|
||||||
|
connectProducedObject := storageMeta.ProducesObject(method)
|
||||||
|
if connectProducedObject == nil {
|
||||||
|
connectProducedObject = "string"
|
||||||
|
}
|
||||||
doc := "connect " + method + " requests to " + kind
|
doc := "connect " + method + " requests to " + kind
|
||||||
if hasSubresource {
|
if hasSubresource {
|
||||||
doc = "connect " + method + " requests to " + subresource + " of " + kind
|
doc = "connect " + method + " requests to " + subresource + " of " + kind
|
||||||
@ -826,7 +830,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
|
|||||||
Operation("connect" + strings.Title(strings.ToLower(method)) + namespaced + kind + strings.Title(subresource) + operationSuffix).
|
Operation("connect" + strings.Title(strings.ToLower(method)) + namespaced + kind + strings.Title(subresource) + operationSuffix).
|
||||||
Produces("*/*").
|
Produces("*/*").
|
||||||
Consumes("*/*").
|
Consumes("*/*").
|
||||||
Writes("string")
|
Writes(connectProducedObject)
|
||||||
if versionedConnectOptions != nil {
|
if versionedConnectOptions != nil {
|
||||||
if err := addObjectParams(ws, route, versionedConnectOptions); err != nil {
|
if err := addObjectParams(ws, route, versionedConnectOptions); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user