Skip to content

Commit

Permalink
Fix Incorrect response model for pods/{name}/log
Browse files Browse the repository at this point in the history
The swagger spec for pods/{name}/log does not include
"text/plain" as a possible content-type for the the response.
So we implement ProducesMIMETypes to make sure "text/plain"
gets added to the default list ot content-types.

the v1.json was generated by running:
hack/update-generated-swagger-docs.sh;./hack/update-swagger-spec.sh;

Fixes kubernetes#14071
  • Loading branch information
dims committed Aug 5, 2016
1 parent 7f528c6 commit e7a46a7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/swagger-spec/v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8817,6 +8817,7 @@
}
],
"produces": [
"text/plain",
"application/json",
"application/yaml",
"application/vnd.kubernetes.protobuf"
Expand Down
3 changes: 3 additions & 0 deletions docs/api-reference/v1/operations.html
Original file line number Diff line number Diff line change
Expand Up @@ -8705,6 +8705,9 @@ <h4 id="_produces_62">Produces</h4>
<div class="ulist">
<ul>
<li>
<p>text/plain</p>
</li>
<li>
<p>application/json</p>
</li>
<li>
Expand Down
10 changes: 10 additions & 0 deletions pkg/registry/pod/rest/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ func (r *LogREST) New() runtime.Object {
return &api.Pod{}
}

// LogREST implements StorageMetadata
func (r *LogREST) ProducesMIMETypes(verb string) []string {
// Since the default list does not include "plain/text", we need to
// explicitly override ProducesMIMETypes, so that it gets added to
// the "produces" section for pods/{name}/log
return []string{
"text/plain",
}
}

// 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)
Expand Down

0 comments on commit e7a46a7

Please sign in to comment.