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

Fix listing all namespaces when base URL is specified #424

Merged
merged 5 commits into from
Jul 1, 2024

Conversation

jacobtomlinson
Copy link
Member

Fixes the issues covered in #284. When specifying the baseurl of a server there seems to be a couple of problems with constructing the API urls.

I also noticed that when setting kr8s.api(url="...") the load kubeconfig code is never called, so the default namespace is never loaded. I added a quick workaround for this so that we get the default namespace, but I'm not sure if this is correct behaviour. I'll open a new issue to explore this further.

@jacobtomlinson jacobtomlinson added bug Something isn't working auth Authenticating with Kubernetes labels Jul 1, 2024
@@ -130,7 +131,7 @@ def _construct_url(
parts = [base]
if version:
parts.append(version)
if namespace is not None:
if namespace:
Copy link
Member Author

Choose a reason for hiding this comment

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

When using a URL with a base url component and setting namespace=kr8s.ALL this can end up as an empty string. So modifying the if statement to catch that case.

@@ -111,6 +111,7 @@ async def _create_session(self) -> None:
headers=headers,
verify=await self.auth.ssl_context(),
timeout=self._timeout,
follow_redirects=True,
Copy link
Member Author

Choose a reason for hiding this comment

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

If a baseurl is set we may get redirected. By default httpx doesn't follow redirects, but we probably always want to.

@github-actions github-actions bot removed the tests label Jul 1, 2024
Copy link

codecov bot commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.27%. Comparing base (87063fc) to head (bb6f5ce).
Report is 119 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #424      +/-   ##
==========================================
+ Coverage   94.61%   95.27%   +0.65%     
==========================================
  Files          29       30       +1     
  Lines        3141     3661     +520     
==========================================
+ Hits         2972     3488     +516     
- Misses        169      173       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jacobtomlinson jacobtomlinson merged commit 5f11b89 into kr8s-org:main Jul 1, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth Authenticating with Kubernetes bug Something isn't working kr8s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant