Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for binary/octet-stream. #5892

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,15 @@ private RestTemplate initRestTemplate(HttpClientBuilder clientBuilder, boolean w
.setDefaultRequestConfig(RequestConfig.custom().setNormalizeUri(false).build())
.build());

// DockerHub response's media-type is application/octet-stream although the content is in JSON.
// Similarly the Github CR response's media-type is always text/plain although the content is in JSON.
// Therefore we extend the MappingJackson2HttpMessageConverter media-types to
// include application/octet-stream and text/plain.
// Extend the MappingJackson2HttpMessageConverter to support the following:
// - DockerHub response media-type is application/octet-stream although the content is in JSON
// - Github CR response media-type is text/plain although the content is in JSON
// - quay.io response media-type is binary/octet-stream although the content is in JSON
MappingJackson2HttpMessageConverter octetSupportJsonConverter = new MappingJackson2HttpMessageConverter();
ArrayList<MediaType> mediaTypeList = new ArrayList(octetSupportJsonConverter.getSupportedMediaTypes());
mediaTypeList.add(MediaType.APPLICATION_OCTET_STREAM);
mediaTypeList.add(MediaType.TEXT_PLAIN);
onobc marked this conversation as resolved.
Show resolved Hide resolved
mediaTypeList.add(MediaType.parseMediaType("binary/octet-stream")); // quay.io responds with binary/octet-stream instead of application/octet-stream
onobc marked this conversation as resolved.
Show resolved Hide resolved
onobc marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be a good idea to ensure we have test coverage for this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That can only be added with integration test using a quay.io container. We don't have existing integration tests for any of the registries.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case a manual test will suffice. But let's be sure we do the manual test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corneil if you can confirm this I will approve and merge this. Thanks.

octetSupportJsonConverter.setSupportedMediaTypes(mediaTypeList);

return restTemplateBuilder
Expand Down
Loading