kloudlite / kl

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

stopall cmd added, status and connect command added #180

Closed nxtcoder36 closed 1 week ago

nxtcoder36 commented 1 week ago

Summary by Sourcery

Add a new 'stop-all' command to stop all running containers and fix a typo in the SSH readiness function name. Enhance user feedback with updated spinner messages and improve error handling in the status command.

New Features:

Bug Fixes:

Enhancements:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

This pull request adds new commands and improves existing functionality in the Kloudlite CLI tool. The changes include adding a 'stopall' command, enhancing the 'status' and 'connect' commands, and improving error handling and user feedback throughout the codebase.

Class diagram for the client class changes

classDiagram
    class client {
        +startContainer(klconfHash string) string
        +waitForSshReady(port int, containerId string) error
        +stopAllContainers() error
    }
    class spinner {
        +UpdateMessage(message string) func()
    }
    client --> spinner : uses
    client : +startContainer(klconfHash string)
    client : +waitForSshReady(port int, containerId string)
    client : +stopAllContainers() error

Class diagram for the new stopAllCmd command

classDiagram
    class stopAllCmd {
        +Run(cmd *cobra.Command, args []string)
    }
    class dockerclient {
        +NewClientWithOpts(...)
        +ContainerList(...)
        +ContainerStop(...)
        +ContainerRemove(...)
    }
    stopAllCmd --> dockerclient : uses
    stopAllCmd : +Run(cmd *cobra.Command, args []string)

File-Level Changes

Change Details Files
Added 'stopall' command to stop all running boxes
  • Implemented a new 'stop-all' command with an alias 'stopall'
  • Added user confirmation before stopping all containers
  • Implemented logic to stop and remove all containers except for k3s-related ones
cmd/box/klbox.go
cmd/box/stop-all.go
Enhanced status command with improved error handling and output
  • Added specific error message for unsynced kl file
  • Improved handling of k3s tracker errors
  • Updated output messages for local cluster and edge connection status
cmd/status/status.go
Improved container management and SSH functionality
  • Fixed typo in function name from 'waithForSshReady' to 'waitForSshReady'
  • Added logging for container startup process
  • Improved error handling in SSH connection checking
cmd/box/boxpkg/utils.go
cmd/box/boxpkg/ssh.go
pkg/sshclient/ssh.go
Enhanced user feedback and progress indication
  • Added spinner messages for various operations
  • Improved logging output for better readability
cmd/box/boxpkg/utils.go
cmd/box/boxpkg/packagectrl/main.go
k3s/impl.go
Improved error handling and edge cases in various commands
  • Added check for empty container list in k3s server stop function
  • Improved error handling in connect command
  • Enhanced error messages and logging throughout the codebase
cmd/cluster/down.go
cmd/connect/connect.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).