fix(docker): added a workaround for port not being set correctly during a redirect to S3 #4733
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
got
module has a known bug (sindresorhus/got#719) where if a request is made with a port (for example 5000) and a redirect is returned,got
will use the original request's port (5000) except the redirected endpoint is likely expecting 80 or 443 if its AWS s3. If a port is specified in the redirect url, thengot
uses the new port.This PR adds a workaround to check to see if there is a port in the url returned by a redirect when attempting to download the docker image blob. If there is not one, then it deletes it from the redirect options and then
got
will use 80 or 443 as a default. This can probably be removed when Renovate upgrades togot
v10.I had a lot of trouble trying to get the new tests to run in inside
datasource/docker.spec.ts
sincegot
is mocked there already, and I couldn't get it to unmock. So, I created a new test file instead usingnock
to try different port combinations between the get and redirect requests. Let me know if you have feedback, I'm willing to make adjustments - Also, I'm fairly new to typescript myself and still learning it.I'm excited to see this be merged in, once it is, we can begin to renovate dockerfiles!
Closes #4593