K8s support#58
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThe recent changes significantly enhance Kubernetes support within the Changes
Assessment against linked issues
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 10
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files ignored due to path filters (2)
docs/source/_static/logo-extended.pngis excluded by!**/*.png,!**/*.pngpyproject.tomlis excluded by!**/*.toml
Files selected for processing (19)
- .github/workflows/auto-assign.yml (1 hunks)
- .grazie.en.yaml (1 hunks)
- Makefile (2 hunks)
- docs/source/index.rst (1 hunks)
- docs/source/k8s/context.rst (1 hunks)
- docs/source/k8s/index.rst (1 hunks)
- docs/source/k8s/namespace.rst (1 hunks)
- docs/source/k8s/pod.rst (1 hunks)
- src/hckr/cli/init.py (3 hunks)
- src/hckr/cli/k8s/init.py (1 hunks)
- src/hckr/cli/k8s/context.py (1 hunks)
- src/hckr/cli/k8s/namespace.py (1 hunks)
- src/hckr/cli/k8s/pod.py (1 hunks)
- src/hckr/utils/CronUtils.py (2 hunks)
- src/hckr/utils/k8s/K8sUtils.py (1 hunks)
- src/hckr/utils/k8s/PodUtils.py (1 hunks)
- tests/cli/k8s/test_context.py (1 hunks)
- tests/cli/k8s/test_namespace.py (1 hunks)
- tests/cli/k8s/test_pod.py (1 hunks)
Files skipped from review due to trivial changes (8)
- .github/workflows/auto-assign.yml
- .grazie.en.yaml
- docs/source/index.rst
- docs/source/k8s/context.rst
- docs/source/k8s/index.rst
- docs/source/k8s/namespace.rst
- docs/source/k8s/pod.rst
- src/hckr/utils/CronUtils.py
Additional context used
Ruff
src/hckr/cli/k8s/namespace.py
3-3:
...utils.MessageUtils.infoimported but unusedRemove unused import:
...utils.MessageUtils.info(F401)
tests/cli/k8s/test_pod.py
5-5:
pyarrowimported but unusedRemove unused import:
pyarrow(F401)
7-7:
pyarrow.parquetimported but unusedRemove unused import:
pyarrow.parquet(F401)
tests/cli/k8s/test_context.py
3-3:
unittest.mock.MagicMockimported but unusedRemove unused import:
unittest.mock.MagicMock(F401)
5-5:
pyarrowimported but unusedRemove unused import:
pyarrow(F401)
7-7:
pyarrow.parquetimported but unusedRemove unused import:
pyarrow.parquet(F401)
tests/cli/k8s/test_namespace.py
5-5:
pyarrowimported but unusedRemove unused import:
pyarrow(F401)
7-7:
pyarrow.parquetimported but unusedRemove unused import:
pyarrow.parquet(F401)
src/hckr/utils/k8s/PodUtils.py
2-2:
reimported but unusedRemove unused import:
re(F401)
15-15: Redefinition of unused
loggingfrom line 1Remove definition:
logging(F811)
91-92: Use a single
ifstatement instead of nestedifstatementsCombine
ifstatements usingand(SIM102)
Additional comments not posted (28)
src/hckr/cli/k8s/__init__.py (3)
1-1: Importclickis correct.The import statement for the
clicklibrary is necessary for defining CLI commands.
4-10: Decoratorcommon_k8s_optionsis well-defined.The decorator correctly adds a
--contextoption to the decorated function, providing a helpful description.
13-18: Click groupk8sis correctly set up.The
k8sClick group is defined with appropriate help text and context settings.src/hckr/cli/k8s/context.py (2)
6-11: Click groupcontextis correctly set up.The
contextClick group is defined with appropriate help text and context settings.
14-29: Commandshowis well-defined but has an unused import.The
showcommand correctly lists all contexts usinglist_contexts. However, theinfofunction is imported but not used.- info("Listing all contexts")Likely invalid or redundant comment.
src/hckr/cli/k8s/namespace.py (1)
6-11: Click groupnamespaceis correctly set up.The
namespaceClick group is defined with appropriate help text and context settings.tests/cli/k8s/test_pod.py (1)
15-26: LGTM! Consider adding more tests.The test method correctly mocks the Kubernetes API, invokes the CLI command, and asserts the output.
However, consider adding tests for other functionalities like delete, logs, etc.
tests/cli/k8s/test_context.py (1)
15-32: LGTM! Consider adding more tests.The test method correctly mocks the Kubernetes config, invokes the CLI command, and asserts the output.
However, consider adding tests for other functionalities like switching contexts, error handling, etc.
tests/cli/k8s/test_namespace.py (2)
15-25: LGTM! Consider adding more tests.The test method correctly mocks the Kubernetes API, invokes the CLI command, and asserts the output.
However, consider adding tests for other functionalities like error handling, different contexts, etc.
26-35: LGTM! Consider adding more tests.The test method correctly mocks the Kubernetes API, invokes the CLI command with a context argument, and asserts the output.
However, consider adding tests for other functionalities like error handling, different contexts, etc.
Makefile (2)
24-24: LGTM! Thesynctarget enhancement is beneficial.Including
fixas a dependency in thesynctarget ensures that any necessary fixes are applied during synchronization, enhancing the build process.
88-91: LGTM! Theruntarget is a valuable addition.The
runtarget facilitates local testing by verifying the presence of thehckrcommand and executing it, streamlining the testing workflow for developers.src/hckr/utils/k8s/K8sUtils.py (3)
24-39: LGTM! The_human_readable_agefunction is well-implemented.The function effectively converts a timestamp to a human-readable age format, handling various time units appropriately.
42-60: LGTM! Thelist_namespacesfunction is well-implemented.The function effectively lists Kubernetes namespaces and displays them using
rich, handling context loading and output formatting appropriately.
63-84: LGTM! Thelist_contextsfunction is well-implemented.The function effectively lists Kubernetes contexts and displays them using
rich, handling context listing and output formatting appropriately.src/hckr/cli/__init__.py (4)
9-11: LGTM! The new imports for Kubernetes operations are necessary.The new imports for Kubernetes operations (
context,namespace,pod) are essential for the added functionalities in the CLI.
5-5: LGTM! The removal of theartimport is appropriate.The removal of the
artimport indicates a shift away from its usage in the CLI, streamlining the import structure.
96-100: LGTM! The new command registrations for Kubernetes operations enhance the CLI.The new command registrations for Kubernetes operations (
k8s,pod,namespace,context) significantly enhance the CLI's capabilities, allowing users to interact with Kubernetes resources directly from thehckrCLI.
Line range hint
36-36:
LGTM! The removal of theart.tprint("hckr")line streamlines the output.The removal of the
art.tprint("hckr")line may streamline the output when the command is invoked without any subcommands, providing a cleaner user experience.src/hckr/cli/k8s/pod.py (5)
9-14: LGTM!The
podfunction is correctly defined as a click group command.
17-56: LGTM!The
showfunction is well-defined and uses appropriate options and arguments.
59-77: LGTM!The
deletefunction is well-defined and uses appropriate options and arguments.
80-102: LGTM!The
shellfunction is well-defined and uses appropriate options and arguments.
105-130: LGTM!The
logsfunction is well-defined and uses appropriate options and arguments.src/hckr/utils/k8s/PodUtils.py (4)
34-67: LGTM!The
list_podsfunction is well-defined and uses appropriate methods to fetch and display pod information.
70-81: LGTM!The
delete_podfunction is well-defined and handles exceptions appropriately.
84-155: LGTM!The
shell_into_podfunction is well-defined and handles input and output streams appropriately.Tools
Ruff
91-92: Use a single
ifstatement instead of nestedifstatementsCombine
ifstatements usingand(SIM102)
158-201: LGTM!The
get_pod_logsfunction is well-defined and handles exceptions appropriately.
There was a problem hiding this comment.
Actionable comments posted: 0
Outside diff range, codebase verification and nitpick comments (3)
tests/cli/k8s/test_context.py (1)
15-32: Ensure assertions are used instead of print statements.Replace the
- print(result.output) - # self.assertEqual(result.exit_code, 0) + self.assertEqual(result.exit_code, 0) + self.assertIn("Listing all contexts", result.output) + self.assertIn("dev <- active", result.output) + self.assertIn("prod", result.output)tests/cli/k8s/test_namespace.py (2)
15-25: Ensure assertions are used instead of print statements.Replace the
- print(result.output) + self.assertEqual(result.exit_code, 0) + self.assertIn("Using default context: default", result.output)
26-35: Ensure assertions are used instead of print statements.Replace the
- print(result.output) + self.assertEqual(result.exit_code, 0) + self.assertIn("Using given context: mycontext", result.output)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- tests/cli/k8s/test_context.py (1 hunks)
- tests/cli/k8s/test_namespace.py (1 hunks)
Additional context used
Ruff
tests/cli/k8s/test_context.py
3-3:
unittest.mock.MagicMockimported but unusedRemove unused import:
unittest.mock.MagicMock(F401)
5-5:
pyarrowimported but unusedRemove unused import:
pyarrow(F401)
7-7:
pyarrow.parquetimported but unusedRemove unused import:
pyarrow.parquet(F401)
tests/cli/k8s/test_namespace.py
5-5:
pyarrowimported but unusedRemove unused import:
pyarrow(F401)
7-7:
pyarrow.parquetimported but unusedRemove unused import:
pyarrow.parquet(F401)
Additional comments not posted (2)
tests/cli/k8s/test_context.py (1)
3-7: Remove unused imports.The imports
unittest.mock.MagicMock,pyarrow, andpyarrow.parquetare not used in this file.- from unittest.mock import patch, MagicMock # type: ignore - import pyarrow as pa # type: ignore - from pyarrow import parquet as pq # type: ignore + from unittest.mock import patch # type: ignoreTools
Ruff
3-3:
unittest.mock.MagicMockimported but unusedRemove unused import:
unittest.mock.MagicMock(F401)
5-5:
pyarrowimported but unusedRemove unused import:
pyarrow(F401)
7-7:
pyarrow.parquetimported but unusedRemove unused import:
pyarrow.parquet(F401)
tests/cli/k8s/test_namespace.py (1)
5-7: Remove unused imports.The imports
pyarrowandpyarrow.parquetare not used in this file.- import pyarrow as pa # type: ignore - from pyarrow import parquet as pq # type: ignoreTools
Ruff
5-5:
pyarrowimported but unusedRemove unused import:
pyarrow(F401)
7-7:
pyarrow.parquetimported but unusedRemove unused import:
pyarrow.parquet(F401)
|


Closes #57