Destroy machine + remove data dir when machine id is set to empty value
This commit is contained in:
parent
29d005dd72
commit
31e57414b4
@ -34,8 +34,12 @@ func (m *Machine) ID() (id string, err error) {
|
||||
|
||||
// SetID implements core.Machine
|
||||
func (m *Machine) SetID(value string) (err error) {
|
||||
m.machine.Id = value
|
||||
return m.SaveMachine()
|
||||
if value == "" {
|
||||
return m.Destroy()
|
||||
} else {
|
||||
m.machine.Id = value
|
||||
return m.SaveMachine()
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Machine) Box() (b core.Box, err error) {
|
||||
|
||||
@ -3,6 +3,7 @@ package core
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@ -218,6 +219,7 @@ func (t *Target) Destroy() (err error) {
|
||||
_, err = t.Client().DeleteTarget(t.ctx, &vagrant_server.DeleteTargetRequest{
|
||||
Target: t.Ref().(*vagrant_plugin_sdk.Ref_Target),
|
||||
})
|
||||
os.RemoveAll(t.dir.DataDir().String())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user