Replace requests module with standard library http #5294
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.
Description
There's no need to pull in an extra dependency for such a simple use case.
Use the EC2 hostname as an override. This way, the normalization also applies to EC2 hostnames, and it saves one intermediary function. The tests are now OS dependent, since the Windows specific functionality can now only be targeted on Windows, but that's not a problem since the CI takes care of running the Windows
tests.
Add a context to the internal GetNodename implementation so that there's proper context propagation internally. External context propagation may be done in the future. Use the context to override the metadata URL in tests. This allows the URL parameter, which was used for testing only, to be removed from the function signature.
Rename nodehostname*.go to nodename*.go. This reflects the public function name declared in these files. Move Windows-specific things into their own files, so that they are only compiled on Windows. Make the test assertions more accurate. Retrieve the Kubernetes hostname once and reuse it in the assertions. Assert the concrete Windows hostname that's returned by the fake server.
Type of change
How Has This Been Tested?
Checklist: