kloudlite / kl

Kloudlite CLI Client
GNU Affero General Public License v3.0
5 stars 1 forks source link

Karthik/wip #176

Closed nxtcoder36 closed 1 week ago

nxtcoder36 commented 1 week ago

Summary by Sourcery

Refactor the codebase to replace k3s-specific logic with a more generic cluster management approach. Introduce a new cluster command for managing clusters, and update the interception and VPN configuration logic to support device-specific and cluster-specific settings. Remove deprecated k3s-related code and update Docker build processes to include version tagging.

New Features:

Enhancements:

Chores:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This pull request implements significant changes to the Kloudlite CLI and related components, focusing on improving cluster management, VPN configuration, and overall system architecture. The changes include updates to the API client, file client, and various command implementations.

Sequence diagram for InterceptApp function

sequenceDiagram
    participant User
    participant apiClient
    participant fileclient
    User->>apiClient: Call InterceptApp
    apiClient->>fileclient: GetVpnTeamConfig
    fileclient-->>apiClient: Return VpnTeamConfig
    apiClient->>fileclient: GetClusterConfig
    fileclient-->>apiClient: Return ClusterConfig
    apiClient-->>User: Return result

Architecture diagram for cluster management

graph TD;
    subgraph Kloudlite CLI
        A[API Client]
        B[File Client]
        C[Cluster Command]
    end
    subgraph Cluster Management
        D[Cluster Config]
        E[VPN Config]
    end
    A --> D
    B --> E
    C --> D
    C --> E
    D --> E
    style D fill:#f9f,stroke:#333,stroke-width:4px;
    style E fill:#bbf,stroke:#333,stroke-width:4px;

Updated class diagram for API client and file client

classDiagram
    class apiClient {
        +InterceptApp(app: App, status: bool, ports: []AppPort, envName: string, options: ...fn.Option) error
        +CreateDevice(devName: string, displayName: string, team: string) (*Device, error)
        +GetClusterConfig(team: string) (*fileclient.TeamClusterConfig, error)
    }
    class fileclient {
        +CurrentTeamName() (string, error)
        +GetWGConfig() (*WGConfig, error)
    }
    class TeamClusterConfig {
        +GatewayIP: string
        +ClusterCIDR: string
    }
    class TeamVpnConfig {
        +IpAddress: string
    }
    apiClient --> fileclient
    fileclient --> TeamClusterConfig
    fileclient --> TeamVpnConfig

File-Level Changes

Change Details Files
Refactored cluster management from k3s to a more generic 'cluster' approach
  • Renamed k3s-related functions and variables to more generic 'cluster' terminology
  • Updated cluster creation and management logic
  • Modified cluster configuration handling
cmd/cluster/up.go
cmd/cluster/down.go
cmd/cluster/cluster.go
clis/kl/loadsubs.go
cmd/use/account.go
Enhanced VPN configuration and management
  • Added support for team-specific VPN configurations
  • Updated VPN configuration generation and application
  • Integrated VPN setup with cluster management
domain/apiclient/device.go
domain/fileclient/device.go
klbox-docker/start.sh
cmd/box/boxpkg/start.go
Improved API client and file client implementations
  • Added new methods for handling cluster and VPN configurations
  • Updated existing methods to support new features
  • Refactored code for better modularity and reusability
domain/apiclient/app.go
domain/apiclient/k3s-local.go
domain/fileclient/account.go
domain/fileclient/context.go
domain/fileclient/k3s-local.go
Updated CLI commands and their implementations
  • Refactored 'use team' command to handle cluster management
  • Updated 'intercept' and 'clone' commands to work with new cluster management
  • Added new 'cluster' command and subcommands
cmd/use/env.go
cmd/use/account.go
cmd/intercept/intercept.go
cmd/intercept/stop.go
cmd/clone/env.go
clis/kl/loadsubs.go
Improved error handling and logging
  • Added more detailed error messages and logging statements
  • Implemented better error handling in various components
cmd/box/boxpkg/utils.go
cmd/box/boxpkg/info.go
domain/fileclient/account.go

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).