Skip to content

Commit

Permalink
Merge pull request #13466 from baude/machinermf
Browse files Browse the repository at this point in the history
machine rm -f stops and removes machine
  • Loading branch information
openshift-merge-robot authored Mar 9, 2022
2 parents 951c681 + 5b51b42 commit 3e870f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cmd/podman/machine/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func init() {

flags := rmCmd.Flags()
formatFlagName := "force"
flags.BoolVar(&destoryOptions.Force, formatFlagName, false, "Do not prompt before rming")
flags.BoolVarP(&destoryOptions.Force, formatFlagName, "f", false, "Stop and do not prompt before rming")

keysFlagName := "save-keys"
flags.BoolVar(&destoryOptions.SaveKeys, keysFlagName, false, "Do not delete SSH keys")
Expand All @@ -64,7 +64,7 @@ func rm(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
confirmationMessage, remove, err := vm.Remove(vmName, machine.RemoveOptions{})
confirmationMessage, remove, err := vm.Remove(vmName, destoryOptions)
if err != nil {
return err
}
Expand Down
8 changes: 6 additions & 2 deletions docs/source/markdown/podman-machine-rm.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ is used.

Print usage statement.

#### **--force**
#### **--force**, **-f**

Delete without confirmation
Stop and delete without confirmation

#### **--save-ignition**

Expand Down Expand Up @@ -58,6 +58,10 @@ The following files will be deleted:
Are you sure you want to continue? [y/N] y
```

```
$ podman machine rm -f test1
$
```
## SEE ALSO
**[podman(1)](podman.1.md)**, **[podman-machine(1)](podman-machine.1.md)**

Expand Down
2 changes: 1 addition & 1 deletion pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, fun
if err != nil {
return "", nil, err
}
if running {
if running && !opts.Force {
return "", nil, errors.Errorf("running vm %q cannot be destroyed", v.Name)
}

Expand Down

0 comments on commit 3e870f8

Please sign in to comment.