Skip to content

Commit 037c5c4

Browse files
author
Konikz
committed
2 parents 4983fb0 + 4c82f35 commit 037c5c4

36 files changed

+400
-186
lines changed

Diff for: .github/workflows/codeql.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3333

3434
- name: Initialize CodeQL
35-
uses: github/codeql-action/init@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
35+
uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
3636
with:
3737
languages: ${{ matrix.language }}
3838
build-mode: ${{ matrix.build-mode }}
@@ -48,6 +48,6 @@ jobs:
4848
exit 1
4949
5050
- name: Perform CodeQL Analysis
51-
uses: github/codeql-action/analyze@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
51+
uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
5252
with:
5353
category: "/language:${{matrix.language}}"

Diff for: .github/workflows/scorecard.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,6 @@ jobs:
6060
# Upload the results to GitHub's code scanning dashboard (optional).
6161
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
6262
- name: "Upload to code-scanning"
63-
uses: github/codeql-action/upload-sarif@1b549b9259bda1cb5ddde3b41741a82a2d15a841 # v3.28.13
63+
uses: github/codeql-action/upload-sarif@45775bd8235c68ba998cffa5171334d58593da47 # v3.28.15
6464
with:
6565
sarif_file: results.sarif

Diff for: .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
- name: Verify generated files
4040
run: make install-tools generate check-generated
4141
- name: Run golangci-lint
42-
uses: golangci/golangci-lint-action@a5307c8f68bcd21ff73283f8629eb09caa60d7a7 # v7.0.0
42+
uses: golangci/golangci-lint-action@1481404843c368bc19ca9406f87d6e0fc97bdcfd # v7.0.0
4343
with:
4444
version: v2.0.1
4545
args: --verbose

Diff for: cmd/lima-guestagent/daemon_linux.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import (
2121
func newDaemonCommand() *cobra.Command {
2222
daemonCommand := &cobra.Command{
2323
Use: "daemon",
24-
Short: "run the daemon",
24+
Short: "Run the daemon",
2525
RunE: daemonAction,
2626
}
27-
daemonCommand.Flags().Duration("tick", 3*time.Second, "tick for polling events")
28-
daemonCommand.Flags().Int("vsock-port", 0, "use vsock server instead a UNIX socket")
29-
daemonCommand.Flags().String("virtio-port", "", "use virtio server instead a UNIX socket")
27+
daemonCommand.Flags().Duration("tick", 3*time.Second, "Tick for polling events")
28+
daemonCommand.Flags().Int("vsock-port", 0, "Use vsock server instead a UNIX socket")
29+
daemonCommand.Flags().String("virtio-port", "", "Use virtio server instead a UNIX socket")
3030
return daemonCommand
3131
}
3232

Diff for: cmd/lima-guestagent/install_systemd_linux.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020
func newInstallSystemdCommand() *cobra.Command {
2121
installSystemdCommand := &cobra.Command{
2222
Use: "install-systemd",
23-
Short: "install a systemd unit (user)",
23+
Short: "Install a systemd unit (user)",
2424
RunE: installSystemdAction,
2525
}
26-
installSystemdCommand.Flags().Int("vsock-port", 0, "use vsock server on specified port")
27-
installSystemdCommand.Flags().String("virtio-port", "", "use virtio server instead a UNIX socket")
26+
installSystemdCommand.Flags().Int("vsock-port", 0, "Use vsock server on specified port")
27+
installSystemdCommand.Flags().String("virtio-port", "", "Use virtio server instead a UNIX socket")
2828
return installSystemdCommand
2929
}
3030

Diff for: cmd/lima-guestagent/main_linux.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func newApp() *cobra.Command {
2424
Short: "Do not launch manually",
2525
Version: strings.TrimPrefix(version.Version, "v"),
2626
}
27-
rootCmd.PersistentFlags().Bool("debug", false, "debug mode")
27+
rootCmd.PersistentFlags().Bool("debug", false, "Debug mode")
2828
rootCmd.PersistentPreRunE = func(cmd *cobra.Command, _ []string) error {
2929
debug, _ := cmd.Flags().GetBool("debug")
3030
if debug {

Diff for: cmd/limactl/copy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ func newCopyCommand() *cobra.Command {
3838
GroupID: advancedCommand,
3939
}
4040

41-
copyCommand.Flags().BoolP("recursive", "r", false, "copy directories recursively")
42-
copyCommand.Flags().BoolP("verbose", "v", false, "enable verbose output")
41+
copyCommand.Flags().BoolP("recursive", "r", false, "Copy directories recursively")
42+
copyCommand.Flags().BoolP("verbose", "v", false, "Enable verbose output")
4343

4444
return copyCommand
4545
}

Diff for: cmd/limactl/debug.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func newDebugDNSCommand() *cobra.Command {
3131
Args: WrapArgsError(cobra.RangeArgs(1, 2)),
3232
RunE: debugDNSAction,
3333
}
34-
cmd.Flags().BoolP("ipv6", "6", false, "lookup IPv6 addresses too")
34+
cmd.Flags().BoolP("ipv6", "6", false, "Lookup IPv6 addresses too")
3535
return cmd
3636
}
3737

Diff for: cmd/limactl/delete.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ func newDeleteCommand() *cobra.Command {
2121
deleteCommand := &cobra.Command{
2222
Use: "delete INSTANCE [INSTANCE, ...]",
2323
Aliases: []string{"remove", "rm"},
24-
Short: "Delete an instance of Lima.",
24+
Short: "Delete an instance of Lima",
2525
Args: WrapArgsError(cobra.MinimumNArgs(1)),
2626
RunE: deleteAction,
2727
ValidArgsFunction: deleteBashComplete,
2828
GroupID: basicCommand,
2929
}
30-
deleteCommand.Flags().BoolP("force", "f", false, "forcibly kill the processes")
30+
deleteCommand.Flags().BoolP("force", "f", false, "Forcibly kill the processes")
3131
return deleteCommand
3232
}
3333

Diff for: cmd/limactl/disk.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ $ limactl disk create DISK --size SIZE [--format qcow2]
5959
Args: WrapArgsError(cobra.ExactArgs(1)),
6060
RunE: diskCreateAction,
6161
}
62-
diskCreateCommand.Flags().String("size", "", "configure the disk size")
62+
diskCreateCommand.Flags().String("size", "", "Configure the disk size")
6363
_ = diskCreateCommand.MarkFlagRequired("size")
64-
diskCreateCommand.Flags().String("format", "qcow2", "specify the disk format")
64+
diskCreateCommand.Flags().String("format", "qcow2", "Specify the disk format")
6565
return diskCreateCommand
6666
}
6767

@@ -224,7 +224,7 @@ $ limactl disk delete DISK1 DISK2 ...
224224
RunE: diskDeleteAction,
225225
ValidArgsFunction: diskBashComplete,
226226
}
227-
diskDeleteCommand.Flags().BoolP("force", "f", false, "force delete")
227+
diskDeleteCommand.Flags().BoolP("force", "f", false, "Force delete")
228228
return diskDeleteCommand
229229
}
230230

Diff for: cmd/limactl/editflags/editflags.go

+15-15
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func RegisterEdit(cmd *cobra.Command) {
2424
func registerEdit(cmd *cobra.Command, commentPrefix string) {
2525
flags := cmd.Flags()
2626

27-
flags.Int("cpus", 0, commentPrefix+"number of CPUs") // Similar to colima's --cpu, but the flag name is slightly different (cpu vs cpus)
27+
flags.Int("cpus", 0, commentPrefix+"Number of CPUs") // Similar to colima's --cpu, but the flag name is slightly different (cpu vs cpus)
2828
_ = cmd.RegisterFlagCompletionFunc("cpus", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
2929
var res []string
3030
for _, f := range completeCPUs(runtime.NumCPU()) {
@@ -33,9 +33,9 @@ func registerEdit(cmd *cobra.Command, commentPrefix string) {
3333
return res, cobra.ShellCompDirectiveNoFileComp
3434
})
3535

36-
flags.IPSlice("dns", nil, commentPrefix+"specify custom DNS (disable host resolver)") // colima-compatible
36+
flags.IPSlice("dns", nil, commentPrefix+"Specify custom DNS (disable host resolver)") // colima-compatible
3737

38-
flags.Float32("memory", 0, commentPrefix+"memory in GiB") // colima-compatible
38+
flags.Float32("memory", 0, commentPrefix+"Memory in GiB") // colima-compatible
3939
_ = cmd.RegisterFlagCompletionFunc("memory", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
4040
var res []string
4141
for _, f := range completeMemoryGiB(memory.TotalMemory()) {
@@ -44,36 +44,36 @@ func registerEdit(cmd *cobra.Command, commentPrefix string) {
4444
return res, cobra.ShellCompDirectiveNoFileComp
4545
})
4646

47-
flags.StringSlice("mount", nil, commentPrefix+"directories to mount, suffix ':w' for writable (Do not specify directories that overlap with the existing mounts)") // colima-compatible
47+
flags.StringSlice("mount", nil, commentPrefix+"Directories to mount, suffix ':w' for writable (Do not specify directories that overlap with the existing mounts)") // colima-compatible
4848

49-
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
49+
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
5050
_ = cmd.RegisterFlagCompletionFunc("mount-type", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
5151
return []string{"reverse-sshfs", "9p", "virtiofs"}, cobra.ShellCompDirectiveNoFileComp
5252
})
5353

54-
flags.Bool("mount-writable", false, commentPrefix+"make all mounts writable")
55-
flags.Bool("mount-inotify", false, commentPrefix+"enable inotify for mounts")
54+
flags.Bool("mount-writable", false, commentPrefix+"Make all mounts writable")
55+
flags.Bool("mount-inotify", false, commentPrefix+"Enable inotify for mounts")
5656

57-
flags.StringSlice("network", nil, commentPrefix+"additional networks, e.g., \"vzNAT\" or \"lima:shared\" to assign vmnet IP")
57+
flags.StringSlice("network", nil, commentPrefix+"Additional networks, e.g., \"vzNAT\" or \"lima:shared\" to assign vmnet IP")
5858
_ = cmd.RegisterFlagCompletionFunc("network", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
5959
// TODO: retrieve the lima:* network list from networks.yaml
6060
return []string{"lima:shared", "lima:bridged", "lima:host", "lima:user-v2", "vzNAT"}, cobra.ShellCompDirectiveNoFileComp
6161
})
6262

63-
flags.Bool("rosetta", false, commentPrefix+"enable Rosetta (for vz instances)")
63+
flags.Bool("rosetta", false, commentPrefix+"Enable Rosetta (for vz instances)")
6464

65-
flags.String("set", "", commentPrefix+"modify the template inplace, using yq syntax")
65+
flags.String("set", "", commentPrefix+"Modify the template inplace, using yq syntax")
6666

6767
// negative performance impact: https://gitlab.com/qemu-project/qemu/-/issues/334
68-
flags.Bool("video", false, commentPrefix+"enable video output (has negative performance impact for QEMU)")
68+
flags.Bool("video", false, commentPrefix+"Enable video output (has negative performance impact for QEMU)")
6969
}
7070

7171
// RegisterCreate registers flags related to in-place YAML modification, for `limactl create`.
7272
func RegisterCreate(cmd *cobra.Command, commentPrefix string) {
7373
registerEdit(cmd, commentPrefix)
7474
flags := cmd.Flags()
7575

76-
flags.String("arch", "", commentPrefix+"machine architecture (x86_64, aarch64, riscv64, armv7l, s390x)") // colima-compatible
76+
flags.String("arch", "", commentPrefix+"Machine architecture (x86_64, aarch64, riscv64, armv7l, s390x)") // colima-compatible
7777
_ = cmd.RegisterFlagCompletionFunc("arch", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
7878
return []string{"x86_64", "aarch64", "riscv64", "armv7l", "s390x"}, cobra.ShellCompDirectiveNoFileComp
7979
})
@@ -83,17 +83,17 @@ func RegisterCreate(cmd *cobra.Command, commentPrefix string) {
8383
return []string{"user", "system", "user+system", "none"}, cobra.ShellCompDirectiveNoFileComp
8484
})
8585

86-
flags.Float32("disk", 0, commentPrefix+"disk size in GiB") // colima-compatible
86+
flags.Float32("disk", 0, commentPrefix+"Disk size in GiB") // colima-compatible
8787
_ = cmd.RegisterFlagCompletionFunc("memory", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
8888
return []string{"10", "30", "50", "100", "200"}, cobra.ShellCompDirectiveNoFileComp
8989
})
9090

91-
flags.String("vm-type", "", commentPrefix+"virtual machine type (qemu, vz)") // colima-compatible
91+
flags.String("vm-type", "", commentPrefix+"Virtual machine type (qemu, vz)") // colima-compatible
9292
_ = cmd.RegisterFlagCompletionFunc("vm-type", func(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
9393
return []string{"qemu", "vz"}, cobra.ShellCompDirectiveNoFileComp
9494
})
9595

96-
flags.Bool("plain", false, commentPrefix+"plain mode. Disable mounts, port forwarding, containerd, etc.")
96+
flags.Bool("plain", false, commentPrefix+"Plain mode. Disables mounts, port forwarding, containerd, etc.")
9797
}
9898

9999
func defaultExprFunc(expr string) func(v *flag.Flag) (string, error) {

Diff for: cmd/limactl/hostagent.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
func newHostagentCommand() *cobra.Command {
2525
hostagentCommand := &cobra.Command{
2626
Use: "hostagent INSTANCE",
27-
Short: "run hostagent",
27+
Short: "Run hostagent",
2828
Args: WrapArgsError(cobra.ExactArgs(1)),
2929
RunE: hostagentAction,
3030
Hidden: true,
3131
}
32-
hostagentCommand.Flags().StringP("pidfile", "p", "", "write pid to file")
33-
hostagentCommand.Flags().String("socket", "", "hostagent socket")
34-
hostagentCommand.Flags().Bool("run-gui", false, "run gui synchronously within hostagent")
35-
hostagentCommand.Flags().String("nerdctl-archive", "", "local file path (not URL) of nerdctl-full-VERSION-GOOS-GOARCH.tar.gz")
32+
hostagentCommand.Flags().StringP("pidfile", "p", "", "Write PID to file")
33+
hostagentCommand.Flags().String("socket", "", "Path of hostagent socket")
34+
hostagentCommand.Flags().Bool("run-gui", false, "Run GUI synchronously within hostagent")
35+
hostagentCommand.Flags().String("nerdctl-archive", "", "Local file path (not URL) of nerdctl-full-VERSION-GOOS-GOARCH.tar.gz")
3636
return hostagentCommand
3737
}
3838

Diff for: cmd/limactl/list.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ func newListCommand() *cobra.Command {
3939
listCommand := &cobra.Command{
4040
Use: "list [flags] [INSTANCE]...",
4141
Aliases: []string{"ls"},
42-
Short: "List instances of Lima.",
42+
Short: "List instances of Lima",
4343
Long: `List instances of Lima.
4444
4545
The output can be presented in one of several formats, using the --format <format> flag.
4646
47-
--format json - output in json format
48-
--format yaml - output in yaml format
49-
--format table - output in table format
50-
--format '{{ <go template> }}' - if the format begins and ends with '{{ }}', then it is used as a go template.
47+
--format json - Output in JSON format
48+
--format yaml - Output in YAML format
49+
--format table - Output in table format
50+
--format '{{ <go template> }}' - If the format begins and ends with '{{ }}', then it is used as a go template.
5151
` + store.FormatHelp + `
5252
The following legacy flags continue to function:
5353
--json - equal to '--format json'`,
@@ -57,7 +57,7 @@ The following legacy flags continue to function:
5757
GroupID: basicCommand,
5858
}
5959

60-
listCommand.Flags().StringP("format", "f", "table", "output format, one of: json, yaml, table, go-template")
60+
listCommand.Flags().StringP("format", "f", "table", "Output format, one of: json, yaml, table, go-template")
6161
listCommand.Flags().Bool("list-fields", false, "List fields available for format")
6262
listCommand.Flags().Bool("json", false, "JSONify output")
6363
listCommand.Flags().BoolP("quiet", "q", false, "Only show names")

Diff for: cmd/limactl/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func newApp() *cobra.Command {
7575
}
7676
rootCmd.PersistentFlags().String("log-level", "", "Set the logging level [trace, debug, info, warn, error]")
7777
rootCmd.PersistentFlags().String("log-format", "text", "Set the logging format [text, json]")
78-
rootCmd.PersistentFlags().Bool("debug", false, "debug mode")
78+
rootCmd.PersistentFlags().Bool("debug", false, "Debug mode")
7979
// TODO: "survey" does not support using cygwin terminal on windows yet
8080
rootCmd.PersistentFlags().Bool("tty", isatty.IsTerminal(os.Stdout.Fd()), "Enable TUI interactions such as opening an editor. Defaults to true when stdout is a terminal. Set to false for automation.")
8181
rootCmd.PersistentFlags().BoolP("yes", "y", false, "Alias of --tty=false")
@@ -186,6 +186,7 @@ func newApp() *cobra.Command {
186186
newUnprotectCommand(),
187187
newTunnelCommand(),
188188
newTemplateCommand(),
189+
newRestartCommand(),
189190
)
190191
if runtime.GOOS == "darwin" || runtime.GOOS == "linux" {
191192
rootCmd.AddCommand(startAtLoginCommand())

Diff for: cmd/limactl/restart.go

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// SPDX-FileCopyrightText: Copyright The Lima Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package main
5+
6+
import (
7+
"github.com/lima-vm/lima/pkg/instance"
8+
"github.com/lima-vm/lima/pkg/store"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
func newRestartCommand() *cobra.Command {
13+
restartCmd := &cobra.Command{
14+
Use: "restart INSTANCE",
15+
Short: "Restart a running instance",
16+
Args: WrapArgsError(cobra.MaximumNArgs(1)),
17+
RunE: restartAction,
18+
ValidArgsFunction: restartBashComplete,
19+
GroupID: basicCommand,
20+
}
21+
22+
restartCmd.Flags().BoolP("force", "f", false, "Force stop and restart the instance")
23+
return restartCmd
24+
}
25+
26+
func restartAction(cmd *cobra.Command, args []string) error {
27+
instName := DefaultInstanceName
28+
if len(args) > 0 {
29+
instName = args[0]
30+
}
31+
32+
inst, err := store.Inspect(instName)
33+
if err != nil {
34+
return err
35+
}
36+
37+
force, err := cmd.Flags().GetBool("force")
38+
if err != nil {
39+
return err
40+
}
41+
42+
ctx := cmd.Context()
43+
if force {
44+
return instance.RestartForcibly(ctx, inst)
45+
}
46+
47+
return instance.Restart(ctx, inst)
48+
}
49+
50+
func restartBashComplete(cmd *cobra.Command, _ []string, _ string) ([]string, cobra.ShellCompDirective) {
51+
return bashCompleteInstanceNames(cmd)
52+
}

Diff for: cmd/limactl/shell.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ func newShellCommand() *cobra.Command {
5050

5151
shellCmd.Flags().SetInterspersed(false)
5252

53-
shellCmd.Flags().String("shell", "", "shell interpreter, e.g. /bin/bash")
54-
shellCmd.Flags().String("workdir", "", "working directory")
55-
shellCmd.Flags().Bool("reconnect", false, "reconnect to the SSH session")
53+
shellCmd.Flags().String("shell", "", "Shell interpreter, e.g. /bin/bash")
54+
shellCmd.Flags().String("workdir", "", "Working directory")
55+
shellCmd.Flags().Bool("reconnect", false, "Reconnect to the SSH session")
5656
return shellCmd
5757
}
5858

Diff for: cmd/limactl/show-ssh.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ import (
1919
)
2020

2121
const showSSHExample = `
22-
"cmd" format (default): Full ssh command line.
22+
"cmd" format (default): Full SSH command line
2323
$ limactl show-ssh --format=cmd default
2424
ssh -o IdentityFile="/Users/example/.lima/_config/user" -o User=example -o Hostname=127.0.0.1 -o Port=60022 lima-default
2525
2626
"args" format: Similar to the cmd format but omits "ssh" and the destination address
2727
$ limactl show-ssh --format=args default
2828
-o IdentityFile="/Users/example/.lima/_config/user" -o User=example -o Hostname=127.0.0.1 -o Port=60022
2929
30-
"options" format: ssh option key value pairs
30+
"options" format: SSH option key value pairs
3131
$ limactl show-ssh --format=options default
3232
IdentityFile="/Users/example/.lima/_config/user"
3333
User=example
@@ -54,8 +54,8 @@ func newShowSSHCommand() *cobra.Command {
5454
}
5555
shellCmd := &cobra.Command{
5656
Use: "show-ssh [flags] INSTANCE",
57-
Short: "Show the ssh command line (DEPRECATED; use `ssh -F` instead)",
58-
Long: fmt.Sprintf(`Show the ssh command line (DEPRECATED)
57+
Short: "Show the SSH command line (DEPRECATED; use `ssh -F` instead)",
58+
Long: fmt.Sprintf(`Show the SSH command line (DEPRECATED)
5959
6060
WARNING: 'limactl show-ssh' is deprecated.
6161
Instead, use 'ssh -F %s/default/ssh.config lima-default' .

0 commit comments

Comments
 (0)