MCPcopy
hub / github.com/lima-vm/lima / Delete

Function Delete

pkg/instance/delete.go:16–36  ·  view source on GitHub ↗
(ctx context.Context, inst *limatype.Instance, force bool)

Source from the content-addressed store, hash-verified

14)
15
16func Delete(ctx context.Context, inst *limatype.Instance, force bool) error {
17 if inst.Protected {
18 return errors.New("instance is protected to prohibit accidental removal (Hint: use `limactl unprotect`)")
19 }
20 if !force && inst.Status != limatype.StatusStopped {
21 return fmt.Errorf("expected status %q, got %q", limatype.StatusStopped, inst.Status)
22 }
23
24 StopForcibly(inst)
25
26 if len(inst.Errors) == 0 {
27 if err := unregister(ctx, inst); err != nil {
28 return fmt.Errorf("failed to unregister %q: %w", inst.Dir, err)
29 }
30 }
31 if err := os.RemoveAll(inst.Dir); err != nil {
32 return fmt.Errorf("failed to remove %q: %w", inst.Dir, err)
33 }
34
35 return nil
36}
37
38func unregister(ctx context.Context, inst *limatype.Instance) error {
39 limaDriver, err := driverutil.CreateConfiguredDriver(ctx, inst, 0, "")

Callers 1

deleteActionFunction · 0.92

Calls 2

StopForciblyFunction · 0.85
unregisterFunction · 0.85

Tested by

no test coverage detected