Skip to content

Commit 6a6f5a4

Browse files
Jim Minterk8s-publish-robot
Jim Minter
authored andcommitted
ProducesObject should only update the returned API object resource documentation
Kubernetes-commit: e18eeb2d63f67b1e0dd3e79982beb7879242c3bb
1 parent 44265f9 commit 6a6f5a4

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

pkg/endpoints/installer.go

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
545545
reqScope.MetaGroupVersion = *a.group.MetaGroupVersion
546546
}
547547
for _, action := range actions {
548-
versionedObject := storageMeta.ProducesObject(action.Verb)
549-
if versionedObject == nil {
550-
versionedObject = defaultVersionedObject
548+
producedObject := storageMeta.ProducesObject(action.Verb)
549+
if producedObject == nil {
550+
producedObject = defaultVersionedObject
551551
}
552552
reqScope.Namer = action.Namer
553553

@@ -617,8 +617,8 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
617617
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
618618
Operation("read"+namespaced+kind+strings.Title(subresource)+operationSuffix).
619619
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
620-
Returns(http.StatusOK, "OK", versionedObject).
621-
Writes(versionedObject)
620+
Returns(http.StatusOK, "OK", producedObject).
621+
Writes(producedObject)
622622
if isGetterWithOptions {
623623
if err := addObjectParams(ws, route, versionedGetOptions); err != nil {
624624
return nil, err
@@ -677,9 +677,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
677677
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
678678
Operation("replace"+namespaced+kind+strings.Title(subresource)+operationSuffix).
679679
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
680-
Returns(http.StatusOK, "OK", versionedObject).
681-
Reads(versionedObject).
682-
Writes(versionedObject)
680+
Returns(http.StatusOK, "OK", producedObject).
681+
Reads(defaultVersionedObject).
682+
Writes(producedObject)
683683
addParams(route, action.Params)
684684
routes = append(routes, route)
685685
case "PATCH": // Partially update a resource
@@ -694,9 +694,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
694694
Consumes(string(types.JSONPatchType), string(types.MergePatchType), string(types.StrategicMergePatchType)).
695695
Operation("patch"+namespaced+kind+strings.Title(subresource)+operationSuffix).
696696
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
697-
Returns(http.StatusOK, "OK", versionedObject).
697+
Returns(http.StatusOK, "OK", producedObject).
698698
Reads(metav1.Patch{}).
699-
Writes(versionedObject)
699+
Writes(producedObject)
700700
addParams(route, action.Params)
701701
routes = append(routes, route)
702702
case "POST": // Create a resource.
@@ -717,9 +717,9 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
717717
Param(ws.QueryParameter("pretty", "If 'true', then the output is pretty printed.")).
718718
Operation("create"+namespaced+kind+strings.Title(subresource)+operationSuffix).
719719
Produces(append(storageMeta.ProducesMIMETypes(action.Verb), mediaTypes...)...).
720-
Returns(http.StatusOK, "OK", versionedObject).
721-
Reads(versionedObject).
722-
Writes(versionedObject)
720+
Returns(http.StatusOK, "OK", producedObject).
721+
Reads(defaultVersionedObject).
722+
Writes(producedObject)
723723
addParams(route, action.Params)
724724
routes = append(routes, route)
725725
case "DELETE": // Delete a resource.
@@ -814,6 +814,10 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
814814
routes = append(routes, buildProxyRoute(ws, "OPTIONS", a.prefix, action.Path, kind, resource, subresource, namespaced, requestScope, hasSubresource, action.Params, proxyHandler, operationSuffix))
815815
case "CONNECT":
816816
for _, method := range connecter.ConnectMethods() {
817+
connectProducedObject := storageMeta.ProducesObject(method)
818+
if connectProducedObject == nil {
819+
connectProducedObject = "string"
820+
}
817821
doc := "connect " + method + " requests to " + kind
818822
if hasSubresource {
819823
doc = "connect " + method + " requests to " + subresource + " of " + kind
@@ -825,7 +829,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
825829
Operation("connect" + strings.Title(strings.ToLower(method)) + namespaced + kind + strings.Title(subresource) + operationSuffix).
826830
Produces("*/*").
827831
Consumes("*/*").
828-
Writes("string")
832+
Writes(connectProducedObject)
829833
if versionedConnectOptions != nil {
830834
if err := addObjectParams(ws, route, versionedConnectOptions); err != nil {
831835
return nil, err

0 commit comments

Comments
 (0)