Skip to content

Commit

Permalink
add rm action
Browse files Browse the repository at this point in the history
it adds a basic rm action which do not accept any args. As only the default macadam machine can be init, the rm only works with it.

Signed-off-by: Luca Stocchi <[email protected]>
  • Loading branch information
lstocchi authored and cfergeau committed Jan 28, 2025
1 parent b8352d3 commit 5b7cb5d
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions cmd/macadam/rm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package main

import (
"github.com/cfergeau/macadam/cmd/macadam/registry"
macadam "github.com/cfergeau/macadam/pkg/machinedriver"
"github.com/containers/podman/v5/pkg/machine"
"github.com/spf13/cobra"
)

var (
rmCmd = &cobra.Command{
Use: "rm [options]",
Short: "Remove an existing machine",
Long: "Remove a managed virtual machine ",
RunE: rm,
Args: cobra.MaximumNArgs(0),
Example: `macadam rm`,
}
)

var (
destroyOptions machine.RemoveOptions
)

func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Command: rmCmd,
})
}

func rm(_ *cobra.Command, args []string) error {
driver, err := macadam.GetDriverByMachineName(defaultMachineName)
if err != nil {
return nil
}

return driver.Remove()
}

0 comments on commit 5b7cb5d

Please sign in to comment.