NOISSUE - Fix error handling in NewRemoveVMCmd to ensure proper connection checks before removing a VM (#488)
CI / ci (push) Has been cancelled

* Fix error handling in NewRemoveVMCmd to ensure proper connection checks before removing a VM

Signed-off-by: Sammy Oina <sammyoina@gmail.com>

* Update cli/manager.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Signed-off-by: Sammy Oina <sammyoina@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Sammy Kerata Oina
2025-07-31 19:30:14 +03:00
committed by GitHub
parent 38c2abb294
commit 4b657e5313
+4 -7
View File
@@ -95,15 +95,12 @@ func (c *CLI) NewRemoveVMCmd() *cobra.Command {
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if c.managerClient == nil || c.connectErr != nil {
if err := c.InitializeManagerClient(cmd); err == nil {
defer c.Close()
if err := c.InitializeManagerClient(cmd); err != nil {
printError(cmd, "Failed to connect to manager: %v ❌ ", err)
return
}
}
if c.connectErr != nil {
printError(cmd, "Failed to connect to manager: %v ❌ ", c.connectErr)
return
}
defer c.Close()
cmd.Println("🔗 Removing virtual machine")