Skip to content

Commit dbf3cd9

Browse files
authored
Merge pull request #3647 from AkihiroSuda/editflags-mount-none
editflags: add `--mount-none`
2 parents 279c1aa + 45e8e9b commit dbf3cd9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cmd/limactl/editflags/editflags.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package editflags
55

66
import (
7+
"errors"
78
"fmt"
89
"math/bits"
910
"runtime"
@@ -45,6 +46,7 @@ func registerEdit(cmd *cobra.Command, commentPrefix string) {
4546
})
4647

4748
flags.StringSlice("mount", nil, commentPrefix+"Directories to mount, suffix ':w' for writable (Do not specify directories that overlap with the existing mounts)") // colima-compatible
49+
flags.Bool("mount-none", false, commentPrefix+"Remove all mounts")
4850

4951
flags.String("mount-type", "", commentPrefix+"Mount type (reverse-sshfs, 9p, virtiofs)") // Similar to colima's --mount-type=(sshfs|9p|virtiofs), but "reverse-sshfs" is Lima is called "sshfs" in colima
5052
_ = cmd.RegisterFlagCompletionFunc("mount-type", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
@@ -157,6 +159,21 @@ func YQExpressions(flags *flag.FlagSet, newInstance bool) ([]string, error) {
157159
false,
158160
false,
159161
},
162+
{
163+
"mount-none",
164+
func(_ *flag.Flag) (string, error) {
165+
ss, err := flags.GetStringSlice("mount")
166+
if err != nil {
167+
return "", err
168+
}
169+
if len(ss) > 0 {
170+
return "", errors.New("flag `--mount-none` conflicts with `--mount`")
171+
}
172+
return ".mounts = null", nil
173+
},
174+
false,
175+
false,
176+
},
160177
{"mount-type", d(".mountType = %q"), false, false},
161178
{"mount-inotify", d(".mountInotify = %s"), false, true},
162179
{"mount-writable", d(".mounts[].writable = %s"), false, false},

0 commit comments

Comments
 (0)