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

Refactors IsSrcRemoteFileURL to only validate the URL is valid #2563

Merged

Conversation

anguswilliams
Copy link
Contributor

@anguswilliams anguswilliams commented Jun 13, 2023

Fixes #1590

Description

IsSrcRemoteFileURL was doing a http.Get call to make sure the URL was valid, but not surfacing any errors. Because the error from the http.Get call is not handled, some useful information can be buried. It also means kaniko will download the file twice during a build, once to validate, and once to actually add the file to the image.
Removing the http.Get call and validating the URL is valid, and has the correct schema and hostname will stop the double handling, and allow any errors to be surfaced through the error handing in the file download function.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes unit tests
  • Adds integration tests if needed.

See the contribution guide for more details.

Reviewer Notes

  • The code flow looks good.
  • Unit tests and or integration tests added.

`IsSrcRemoteFileURL` was doing a `http.Get` call to make sure the URL was valid, but not surfacing any errors.
Because the error from the http.Get call is not handled, some useful information can be buried.
It also means kaniko will download the file twice during a build, once to validate, and once to actually add the file
to the image.
Removing the http.Get call and validating the URL is valid, and has the correct schema and hostname will stop
the double handling, and allow any errors to be surfaced through the error handing in the file download function.

Fixes GoogleContainerTools#1590

Signed-off-by: Angus Williams <anguswilliams@gmail.com>
Copy link
Collaborator

@aaron-prindle aaron-prindle left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the fix here @anguswilliams!

@aaron-prindle aaron-prindle merged commit de3032f into GoogleContainerTools:main Jun 14, 2023
kylecarbs pushed a commit to coder/kaniko that referenced this pull request Jul 12, 2023
…eContainerTools#2563)

`IsSrcRemoteFileURL` was doing a `http.Get` call to make sure the URL was valid, but not surfacing any errors.
Because the error from the http.Get call is not handled, some useful information can be buried.
It also means kaniko will download the file twice during a build, once to validate, and once to actually add the file
to the image.
Removing the http.Get call and validating the URL is valid, and has the correct schema and hostname will stop
the double handling, and allow any errors to be surfaced through the error handing in the file download function.

Fixes GoogleContainerTools#1590

Signed-off-by: Angus Williams <anguswilliams@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ADD with https in URL treated as file
2 participants