kloudlite / kl

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

device locally deleted on logout #185

Closed nxtcoder36 closed 1 week ago

nxtcoder36 commented 1 week ago

Summary by Sourcery

Enhance device creation by adding metadata labels for local UUID and ownership, and implement a method to list VPN devices with filtering. Simplify the logout process by removing the VPN configuration directory. Comment out the spinner update message in the SSH connection check function.

Bug Fixes:

Enhancements:

Chores:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This pull request implements changes to improve device management, enhance security, and optimize the logout process. The main changes include adding device labels for better identification, implementing a local device deletion on logout, and refining SSH connection checks.

Sequence diagram for CreateDevice process

sequenceDiagram
    participant apic as apiClient
    participant fc as FileClient
    participant kl as Kloudlite
    participant user as User

    apic->>fc: GetWGConfig()
    fc-->>apic: wgconfig
    apic->>apic: GetCurrentUser()
    apic-->>user: user
    apic->>kl: klFetch("cli_createGlobalVPNDevice", {...})
    kl-->>apic: respData
    apic->>apic: Process respData

Sequence diagram for Logout process

sequenceDiagram
    participant fc as FileClient
    participant os as OperatingSystem

    fc->>os: Stat(vpnConfigPath)
    alt vpnConfigPath exists
        fc->>os: RemoveAll(vpnConfigPath)
        os-->>fc: success or error
    end
    fc->>os: Remove(sessionFile)
    os-->>fc: success or error

Updated class diagram for apiClient

classDiagram
    class apiClient {
        +CreateDevice(devName, displayName, team string) *Device
        +CreateVpnForTeam(team string) *Device
        +GetAccVPNConfig(team string) *fileclient.TeamVpnConfig
        +ListVpnDevices(team string) []Device
        +GetClustersOfTeam(team string) []Cluster
    }
    class Device {
        +Metadata: map[string]any
    }
    class User {
        +UserId: string
    }
    apiClient --> Device
    apiClient --> User

Updated class diagram for fclient

classDiagram
    class fclient {
        +Logout() error
    }

File-Level Changes

Change Details Files
Added device labels for better identification and management
  • Added labels for k3scluster, local-uuid, and owned-by
  • Fetched WireGuard configuration and current user information
  • Updated device creation process to include new labels
domain/apiclient/device.go
Implemented local device deletion on logout
  • Replaced individual file processing with complete removal of vpn config directory
  • Simplified logout process by removing all VPN-related files at once
domain/fileclient/auth.go
Added functionality to list VPN devices
  • Implemented ListVpnDevices function to fetch VPN devices for a team
  • Added logic to check for existing devices before creating a new one
domain/apiclient/device.go
Updated cluster listing functionality
  • Added pagination parameter to cli_listAccountClusters API call
domain/apiclient/k3s-local.go
Modified SSH connection check
  • Commented out spinner update message during SSH connection check
pkg/sshclient/ssh.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).