fix: wrong k8s client configuration#576
Conversation
|
Warning Review limit reached
More reviews will be available in 56 minutes and 29 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (2)
Walkthrough
ChangesExplicit K8s Configuration Loading
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tests/test_bonfire_lib/test_k8s_client.py`:
- Around line 66-69: Add a single module-level import for ANY from unittest.mock
at the top of tests/test_bonfire_lib/test_k8s_client.py (add ANY to the existing
import list) and remove the three inline imports like "from unittest.mock import
ANY" inside the individual test functions that call
mock_config.load_incluster_config (the usages around the assertions at the
locations shown). This centralizes the ANY symbol and eliminates the duplicate
in-function imports so ruff/formatting pre-commit checks pass.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: e681f7e0-4887-45df-90c5-fafb43873f63
📒 Files selected for processing (2)
bonfire_lib/k8s_client.pytests/test_bonfire_lib/test_k8s_client.py
| from unittest.mock import ANY | ||
| mock_config.load_incluster_config.assert_called_once_with( | ||
| client_configuration=ANY | ||
| ) |
There was a problem hiding this comment.
Move ANY import to module level to fix pipeline failure.
The from unittest.mock import ANY is imported three times inside test function bodies (lines 66, 82, 114). This is causing the ruff-format pre-commit failure. Import ANY once at the top of the file.
Proposed fix
At line 1, add ANY to the existing import:
-from unittest.mock import patch, MagicMock
+from unittest.mock import ANY, patch, MagicMockThen remove the inline imports from the test functions:
EphemeralK8sClient()
- from unittest.mock import ANY
mock_config.load_incluster_config.assert_called_once_with(
client_configuration=ANY
) EphemeralK8sClient(kubeconfig_path="/tmp/kubeconfig", context="mycontext")
# Verify load_kube_config was called with the right args (client_configuration is ANY)
- from unittest.mock import ANY
mock_config.load_kube_config.assert_called_once_with(
config_file="/tmp/kubeconfig",
context="mycontext",
client_configuration=ANY,
) EphemeralK8sClient()
# Should have fallen back to in-cluster
- from unittest.mock import ANY
mock_config.load_incluster_config.assert_called_once_with(
client_configuration=ANY
)Also applies to: 82-86, 114-117
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@tests/test_bonfire_lib/test_k8s_client.py` around lines 66 - 69, Add a single
module-level import for ANY from unittest.mock at the top of
tests/test_bonfire_lib/test_k8s_client.py (add ANY to the existing import list)
and remove the three inline imports like "from unittest.mock import ANY" inside
the individual test functions that call mock_config.load_incluster_config (the
usages around the assertions at the locations shown). This centralizes the ANY
symbol and eliminates the duplicate in-function imports so ruff/formatting
pre-commit checks pass.
Signed-off-by: JuanmaBM <juanmabareamartinez@gmail.com>
e54f7e5 to
9b5ba5f
Compare
Fix a problem with the k8s configuration