kloudlite / kl

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

k3s up and down cmd implemented, wireguard image removed #156

Closed nxtcoder36 closed 2 weeks ago

nxtcoder36 commented 2 weeks ago

Summary by Sourcery

Implement new CLI commands to start and stop the k3s server, enhance container management with improved stop options, and clean up the codebase by removing obsolete wireguard files.

New Features:

Enhancements:

Chores:

sourcery-ai[bot] commented 2 weeks ago

Reviewer's Guide by Sourcery

This pull request implements the 'k3s up' and 'k3s down' commands, removes the Wireguard image, and makes several improvements to the existing codebase. The changes focus on enhancing the K3s server management, updating the authentication process, and refactoring some utility functions.

Sequence Diagrams

K3s Up Command Flow

sequenceDiagram
    participant User
    participant UpCmd
    participant FileClient
    participant K3sClient
    User->>UpCmd: Execute 'k3s up'
    UpCmd->>FileClient: GetExtraData()
    FileClient-->>UpCmd: Return ExtraData
    UpCmd->>UpCmd: Check SelectedAccount
    UpCmd->>K3sClient: NewClient()
    K3sClient-->>UpCmd: Return K3sClient
    UpCmd->>K3sClient: CreateClustersAccounts(selectedAccount)
    K3sClient-->>UpCmd: Return result
    UpCmd->>User: Display result

K3s Down Command Flow

sequenceDiagram
    participant User
    participant DownCmd
    participant DockerClient
    User->>DownCmd: Execute 'k3s down'
    DownCmd->>DockerClient: NewClientWithOpts()
    DockerClient-->>DownCmd: Return DockerClient
    DownCmd->>DockerClient: ContainerList()
    DockerClient-->>DownCmd: Return container list
    loop For each container
        DownCmd->>DockerClient: ContainerStop()
        DownCmd->>DockerClient: ContainerRemove()
    end
    DownCmd->>User: Display result

File-Level Changes

Change Details Files
Implementation of 'k3s up' and 'k3s down' commands
  • Added new 'up.go' file to implement the 'k3s up' command
  • Added new 'down.go' file to implement the 'k3s down' command
  • Updated 'loadsubs.go' to include the new k3s commands
cmd/k3s/up.go
cmd/k3s/down.go
clis/kl/loadsubs.go
Removal of Wireguard image and related files
  • Deleted 'wireguard/main.go'
  • Deleted 'wireguard/Taskfile.yml'
  • Deleted 'wireguard/healthcheck.sh'
wireguard/main.go
wireguard/Taskfile.yml
wireguard/healthcheck.sh
Refactoring and improvements in K3s server management
  • Updated K3s image name in constants
  • Commented out the K3s server readiness check
  • Modified the ping check command in the K3s server readiness function
  • Updated the container stop logic with a timeout and SIGKILL signal
pkg/k3s/impl.go
constants/main.go
cmd/auth/logout.go
Enhancement of account selection and management
  • Added SelectedAccount field to ExtraData struct
  • Updated UseAccount function to save the selected account
  • Modified the account selection process in the 'k3s up' command
domain/fileclient/context.go
cmd/use/account.go
cmd/k3s/up.go
Code cleanup and minor improvements
  • Removed commented-out code
  • Updated variable names for better readability
  • Improved error handling and messages
pkg/k3s/impl.go
cmd/auth/logout.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. #### 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).