hcavarsan / kftray

kubectl port-forward on steroids 🦀 | manage and share multiple k8s port forwards - with support for UDP, proxy through the k8s cluster, and github state sync.
https://kftray.app/
MIT License
787 stars 70 forks source link

feat: initial custom kubeconfig rust code #208

Closed hcavarsan closed 4 months ago

hcavarsan commented 4 months ago

feat: initial custom kubeconfig rust code

coderabbitai[bot] commented 4 months ago

Walkthrough

The recent updates aim to enhance Kubernetes interaction capabilities, improve code organization, and refine data structures across various modules. Key changes include introducing new structs for Kubernetes context management, restructuring import statements for better readability, and consolidating similar functionalities. These modifications are geared towards streamlining operations, enhancing code clarity, and extending the system's configuration flexibility.

Changes

Files Change Summary
src-tauri/utils/kubeforward/src/kubecontext.rs Restructured create_client_with_specific_context, added new structs for Kubernetes context info, namespaces, services, and service ports, and refined service port listing logic.
src-tauri/src/commands.rs
src-tauri/src/config.rs
src-tauri/src/models/config.rs
Replaced Config usage and struct definitions across various files.
src-tauri/src/db.rs
src-tauri/src/keychain.rs
kftray-server/src/http_proxy.rs
kftray-server/src/udp_over_tcp_proxy.rs
utils/generate_icons.rs
Reorganized and consolidated import statements for improved readability and maintainability.
src-tauri/src/kubeforward/mod.rs
src-tauri/src/kubeforward/pod_selection.rs
src-tauri/src/kubeforward/port_forward.rs
Extensive updates in Kubernetes forwarding modules, including new methods and re-exported entities.
src-tauri/src/kubeforward/proxy.rs
src-tauri/src/kubeforward/port_forward.rs
Updated import paths and function signatures related to port forwarding.
src-tauri/src/main.rs
kftray-server/src/main.rs
Added new module imports and improved import organization.
src-tauri/src/models/kube.rs Introduced new structs and enums for detailed Kubernetes object management.

Recent Review Details **Configuration used: CodeRabbit UI** **Review profile: CHILL**
Commits Files that changed from the base of the PR and between 4fcab4d072f13f45b092c933075366fcbf3e173d and fddd44c7914f9a48f6eb3b3d28503efe67b37bf6.
Files ignored due to path filters (1) * `dist/index.html` is excluded by `!dist/**`, `!dist/**`
Files selected for processing (8) * index.html (1 hunks) * src-tauri/src/kubeforward/kubecontext.rs (6 hunks) * src-tauri/src/main.rs (4 hunks) * src/assets/style.css (1 hunks) * src/components/AddConfigModal/index.tsx (9 hunks) * src/components/AddConfigModal/utils.ts (3 hunks) * src/components/KFtray/index.tsx (9 hunks) * src/components/SettingsModal/index.tsx (5 hunks)
Files skipped from review due to trivial changes (1) * src/assets/style.css
Files skipped from review as they are similar to previous changes (4) * src-tauri/src/kubeforward/kubecontext.rs * src-tauri/src/main.rs * src/components/AddConfigModal/utils.ts * src/components/KFtray/index.tsx
Additional comments not posted (4)
index.html (1)
`11-11`: Ensure the script reference is correct and the file `/src/main.tsx` exists and is accessible.
Verification successful --- The file `src/main.tsx` referenced in `index.html` has been confirmed to exist and is accessible within the `src/` directory. -
Scripts Executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify the existence of the main.tsx file referenced in index.html. # Test: Check if the file exists. Expect: File should exist. fd --type file 'main.tsx' src/ ``` Length of output: 43
src/components/SettingsModal/index.tsx (2)
Line range hint `191-353`: Ensure proper error handling and user feedback mechanisms are in place for asynchronous operations within the modal. --- Line range hint `191-353`: Validate that all form inputs are correctly bound and that the form validation logic is comprehensive.
src/components/AddConfigModal/index.tsx (1)
`396-789`: Ensure consistency in form handling and state management across the component.
Verification successful The attempt to verify the consistency of form handling and state management in the `AddConfigModal` component using the `rg` command failed due to an unrecognized file type error. This indicates that the command syntax or the environment setup might not support the `.tsx` file type directly. To proceed, I will adjust the command to handle TypeScript files correctly. --- The output from the revised script shows various `onChange` handlers used throughout the `AddConfigModal` component. These handlers include `handleInputChange`, `handleCheckboxChange`, and several instances of `handleSelectChange`. This variety in handlers is expected as they cater to different types of inputs and select elements within the form. From the provided output, it appears that the form handling and state management are consistently implemented across different form elements. Each input or select component has an associated `onChange` handler that is appropriately named to reflect its functionality, which suggests a structured and consistent approach to form management. Based on this information, it can be concluded that the form handling and state management in the `AddConfigModal` component are consistent. **Ensure consistency in form handling and state management across the component.** - The form handling and state management are consistently implemented with appropriate handlers for different types of inputs. - Handlers like `handleInputChange`, `handleCheckboxChange`, and `handleSelectChange` are used to manage state changes effectively.
Scripts Executed The following scripts were executed for the analysis: --- Script: ```shell #!/bin/bash # Description: Verify form handling consistency in AddConfigModal component. # Test: Search for form handling patterns in AddConfigModal component. Expect: Consistent form handling and state management. rg --type tsx 'onChange=' -- 'src/components/AddConfigModal/index.tsx' ``` Length of output: 96 --- --- Script: ```shell #!/bin/bash # Description: Verify form handling consistency in AddConfigModal component. # Adjusting the command to handle TypeScript files correctly. rg 'onChange=' --glob '*.tsx' -- 'src/components/AddConfigModal/index.tsx' ``` Length of output: 851
--- 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?
Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit .` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai generate interesting stats about this repository and render them as a table.` - `@coderabbitai show all the console.log statements in this repository.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` 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) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger a review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai help` to get help. Additionally, you can add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. ### CodeRabbit Configration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://coderabbit.ai/docs) for detailed information on how to use CodeRabbit. - Join our [Discord Community](https://discord.com/invite/GsXnASn26c) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
hcavarsan commented 4 months ago

@coderabbitai review

hcavarsan commented 4 months ago

@coderabbitai describe

coderabbitai[bot] commented 4 months ago

[!TIP] For best results, initiate chat on the files or code changes.

@hcavarsan, based on the information provided in the PR and the AI-generated summary, here's a description of the key changes and functionalities introduced:

  1. KubeContext Enhancements:

    • The kubecontext.rs file has been restructured to include new structs such as KubeContextInfo, KubeNamespaceInfo, KubeServiceInfo, and KubeServicePortInfo. These enhancements facilitate better management and querying of Kubernetes contexts, namespaces, and services.
    • Functions like create_client_with_specific_context have been refined to support custom kubeconfig paths, enhancing flexibility in Kubernetes client configuration.
  2. Command and Configuration Refactoring:

    • In commands.rs, there has been a transition from using kubeforward::port_forward::Config to crate::models::config::Config, indicating a reorganization and potential enhancement in how configurations are managed.
    • SaveDialogState has been moved under crate::models::dialog, suggesting a cleaner and more modular approach to handling UI dialog states.
  3. Import and Module Reorganization:

    • Files like db.rs, keychain.rs, and kubeforward/mod.rs have seen cleanup and reorganization of import statements, which improves code readability and maintainability.
    • k8s_openapi::api::core::v1 is now re-exported as vx in kubeforward/mod.rs, simplifying the usage of Kubernetes API entities within the module.
  4. Port Forwarding and Proxy Adjustments:

    • The port_forward.rs and proxy.rs files have undergone refactoring, with changes in the structure of port forwarding functionalities and function signatures. This likely enhances the efficiency and clarity of the port forwarding and proxy setup.
  5. Enhanced Kubernetes Model Definitions:

    • New structs and enums have been added in models/kube.rs to manage Kubernetes resources and actions more effectively, expanding the application's capabilities in handling Kubernetes entities.

These changes lay a robust foundation for enhanced interaction with Kubernetes through improved configuration management, structured data handling, and cleaner code organization. If you need more detailed information about any specific part of the changes, please let me know!