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

Replace requests module with standard library http #5294

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

twz123
Copy link
Member

@twz123 twz123 commented Nov 26, 2024

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

How Has This Been Tested?

  • Manual test
  • Auto test added

Checklist:

  • My code follows the style guidelines of this project
  • My commit messages are signed-off
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

This reflects the public function name declared in these files.

Signed-off-by: Tom Wieczorek <[email protected]>
So that there's proper context propagation internally. External context
propagation may be done in the future.

Signed-off-by: Tom Wieczorek <[email protected]>
This allows the URL parameter, which was used for testing only, to be
removed from the function signature. This is a preparation for unifying
the Windows and non-windows code paths, so that the function signatures
are identical.

Signed-off-by: Tom Wieczorek <[email protected]>
Retrieve the Kubernetes hostname once and reuse it in the assertions.
Assert the concrete Windows hostname that's returned by the fake server.

Signed-off-by: Tom Wieczorek <[email protected]>
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.

Signed-off-by: Tom Wieczorek <[email protected]>
So that they are only compiled on Windows.

Signed-off-by: Tom Wieczorek <[email protected]>
There's no need to pull in an extra dependency for such a simple use
case.

Signed-off-by: Tom Wieczorek <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant