diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json
index f1b54e16bc2a..b53a02e564a2 100644
--- a/api/openapi-spec/swagger.json
+++ b/api/openapi-spec/swagger.json
@@ -3638,7 +3638,7 @@
"200": {
"description": "OK",
"schema": {
- "$ref": "#/definitions/v1.Pod"
+ "type": "string"
}
},
"401": {
diff --git a/api/swagger-spec/v1.json b/api/swagger-spec/v1.json
index 20956dda1e56..4999ca1e4d2a 100644
--- a/api/swagger-spec/v1.json
+++ b/api/swagger-spec/v1.json
@@ -8980,7 +8980,7 @@
"description": "API at /api/v1",
"operations": [
{
- "type": "v1.Pod",
+ "type": "string",
"method": "GET",
"summary": "read log of the specified Pod",
"nickname": "readNamespacedPodLog",
@@ -9078,7 +9078,7 @@
{
"code": 200,
"message": "OK",
- "responseModel": "v1.Pod"
+ "responseModel": "string"
}
],
"produces": [
diff --git a/docs/api-reference/v1/operations.html b/docs/api-reference/v1/operations.html
index 4c8f17c81fa1..886872a701ff 100755
--- a/docs/api-reference/v1/operations.html
+++ b/docs/api-reference/v1/operations.html
@@ -8979,7 +8979,7 @@
Responses
200 |
success |
-v1.Pod |
+string |
diff --git a/pkg/api/rest/rest.go b/pkg/api/rest/rest.go
index c4dd06e079bb..2098ccdbe76a 100644
--- a/pkg/api/rest/rest.go
+++ b/pkg/api/rest/rest.go
@@ -289,6 +289,10 @@ type StorageMetadata interface {
// ProducesMIMETypes returns a list of the MIME types the specified HTTP verb (GET, POST, DELETE,
// PATCH) can respond with.
ProducesMIMETypes(verb string) []string
+
+ // ProducesObject returns an object the specified HTTP verb respond with. It will overwrite storage object if
+ // it is not nil. Only the type of the return object matters, the value will be ignored.
+ ProducesObject(verb string) interface{}
}
// ConnectRequest is an object passed to admission control for Connect operations
diff --git a/pkg/apiserver/api_installer.go b/pkg/apiserver/api_installer.go
index 07a5b066e095..eaf6e2356331 100644
--- a/pkg/apiserver/api_installer.go
+++ b/pkg/apiserver/api_installer.go
@@ -197,7 +197,7 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
if err != nil {
return nil, err
}
- versionedObject := indirectArbitraryPointer(versionedPtr)
+ defaultVersionedObject := indirectArbitraryPointer(versionedPtr)
kind := fqKindToRegister.Kind
hasSubresource := len(subresource) > 0
@@ -503,6 +503,10 @@ func (a *APIInstaller) registerResourceHandlers(path string, storage rest.Storag
Kind: fqKindToRegister,
}
for _, action := range actions {
+ versionedObject := storageMeta.ProducesObject(action.Verb)
+ if versionedObject == nil {
+ versionedObject = defaultVersionedObject
+ }
reqScope.Namer = action.Namer
namespaced := ""
if apiResource.Namespaced {
@@ -1022,6 +1026,10 @@ func (defaultStorageMetadata) ProducesMIMETypes(verb string) []string {
return nil
}
+func (defaultStorageMetadata) ProducesObject(verb string) interface{} {
+ return nil
+}
+
// splitSubresource checks if the given storage path is the path of a subresource and returns
// the resource and subresource components.
func splitSubresource(path string) (string, string, error) {
diff --git a/pkg/apiserver/apiserver_test.go b/pkg/apiserver/apiserver_test.go
index 23ccd3ae8603..34a79c336644 100644
--- a/pkg/apiserver/apiserver_test.go
+++ b/pkg/apiserver/apiserver_test.go
@@ -619,6 +619,10 @@ func (m *MetadataRESTStorage) ProducesMIMETypes(method string) []string {
return m.types
}
+func (m *MetadataRESTStorage) ProducesObject(verb string) interface{} {
+ return nil
+}
+
var _ rest.StorageMetadata = &MetadataRESTStorage{}
type GetWithOptionsRESTStorage struct {
diff --git a/pkg/registry/core/pod/rest/log.go b/pkg/registry/core/pod/rest/log.go
index e396b61732cf..c946eda757f8 100644
--- a/pkg/registry/core/pod/rest/log.go
+++ b/pkg/registry/core/pod/rest/log.go
@@ -55,6 +55,11 @@ func (r *LogREST) ProducesMIMETypes(verb string) []string {
}
}
+// LogREST implements StorageMetadata, return string as the generating object
+func (r *LogREST) ProducesObject(verb string) interface{} {
+ return ""
+}
+
// Get retrieves a runtime.Object that will stream the contents of the pod log
func (r *LogREST) Get(ctx api.Context, name string, opts runtime.Object) (runtime.Object, error) {
logOpts, ok := opts.(*api.PodLogOptions)