Skip to content

Commit 7c84bc4

Browse files
committed
sudoers: show the command only on darwin
Signed-off-by: Oleksandr Redko <[email protected]>
1 parent bf3d444 commit 7c84bc4

File tree

7 files changed

+41
-9
lines changed

7 files changed

+41
-9
lines changed

.ls-lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ ls:
1313
.yaml: snake_case
1414

1515
cmd/limactl:
16-
# valid names are `show-ssh.go` or `show-ssh_test.go`
17-
.go: kebab-case | regex:[a-z0-9-]+_test
16+
# valid names are `show-ssh.go`, `show-ssh_windows.go` or `show-ssh_test.go`
17+
.go: lowercase
1818

1919
docs:
2020
.md: kebab-case

cmd/limactl/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ func newApp() *cobra.Command {
169169
newListCommand(),
170170
newDeleteCommand(),
171171
newValidateCommand(),
172-
newSudoersCommand(),
173172
newPruneCommand(),
174173
newHostagentCommand(),
175174
newInfoCommand(),
@@ -188,8 +187,8 @@ func newApp() *cobra.Command {
188187
newTemplateCommand(),
189188
newRestartCommand(),
190189
)
191-
if runtime.GOOS == "darwin" || runtime.GOOS == "linux" {
192-
rootCmd.AddCommand(startAtLoginCommand())
190+
for _, cmd := range additionalAdvancedCommands() {
191+
rootCmd.AddCommand(cmd)
193192
}
194193

195194
return rootCmd

cmd/limactl/main_darwin.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// SPDX-FileCopyrightText: Copyright The Lima Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package main
5+
6+
import "github.com/spf13/cobra"
7+
8+
func additionalAdvancedCommands() []*cobra.Command {
9+
return []*cobra.Command{
10+
newSudoersCommand(),
11+
startAtLoginCommand(),
12+
}
13+
}

cmd/limactl/main_linux.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// SPDX-FileCopyrightText: Copyright The Lima Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package main
5+
6+
import "github.com/spf13/cobra"
7+
8+
func additionalAdvancedCommands() []*cobra.Command {
9+
return []*cobra.Command{
10+
startAtLoginCommand(),
11+
}
12+
}

cmd/limactl/main_windows.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// SPDX-FileCopyrightText: Copyright The Lima Authors
2+
// SPDX-License-Identifier: Apache-2.0
3+
4+
package main
5+
6+
import "github.com/spf13/cobra"
7+
8+
func additionalAdvancedCommands() []*cobra.Command {
9+
return nil
10+
}

cmd/limactl/start-at-login.go renamed to cmd/limactl/start-at-login_unix.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build !windows
2+
13
// SPDX-FileCopyrightText: Copyright The Lima Authors
24
// SPDX-License-Identifier: Apache-2.0
35

cmd/limactl/sudoers.go renamed to cmd/limactl/sudoers_darwin.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"errors"
88
"fmt"
99
"io"
10-
"runtime"
1110

1211
"github.com/lima-vm/lima/pkg/networks"
1312
"github.com/sirupsen/logrus"
@@ -42,9 +41,6 @@ See %s for the usage.`, networksURL),
4241
}
4342

4443
func sudoersAction(cmd *cobra.Command, args []string) error {
45-
if runtime.GOOS != "darwin" {
46-
return errors.New("sudoers command is only supported on macOS right now")
47-
}
4844
nwCfg, err := networks.LoadConfig()
4945
if err != nil {
5046
return err

0 commit comments

Comments
 (0)