Skip to content

sudoers: show the command only on darwin #3425

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .ls-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ ls:
.yaml: snake_case

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

docs:
.md: kebab-case
Expand Down
5 changes: 2 additions & 3 deletions cmd/limactl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ func newApp() *cobra.Command {
newListCommand(),
newDeleteCommand(),
newValidateCommand(),
newSudoersCommand(),
newPruneCommand(),
newHostagentCommand(),
newInfoCommand(),
Expand All @@ -188,8 +187,8 @@ func newApp() *cobra.Command {
newTemplateCommand(),
newRestartCommand(),
)
if runtime.GOOS == "darwin" || runtime.GOOS == "linux" {
rootCmd.AddCommand(startAtLoginCommand())
for _, cmd := range additionalAdvancedCommands() {
rootCmd.AddCommand(cmd)
}

return rootCmd
Expand Down
13 changes: 13 additions & 0 deletions cmd/limactl/main_darwin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: Copyright The Lima Authors
// SPDX-License-Identifier: Apache-2.0

package main

import "github.com/spf13/cobra"

func additionalAdvancedCommands() []*cobra.Command {
return []*cobra.Command{
newSudoersCommand(),
startAtLoginCommand(),
}
}
12 changes: 12 additions & 0 deletions cmd/limactl/main_linux.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-FileCopyrightText: Copyright The Lima Authors
// SPDX-License-Identifier: Apache-2.0

package main

import "github.com/spf13/cobra"

func additionalAdvancedCommands() []*cobra.Command {
return []*cobra.Command{
startAtLoginCommand(),
}
}
10 changes: 10 additions & 0 deletions cmd/limactl/main_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: Copyright The Lima Authors
// SPDX-License-Identifier: Apache-2.0

package main

import "github.com/spf13/cobra"

func additionalAdvancedCommands() []*cobra.Command {
return nil
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//go:build !windows

// SPDX-FileCopyrightText: Copyright The Lima Authors
// SPDX-License-Identifier: Apache-2.0

Expand Down
4 changes: 0 additions & 4 deletions cmd/limactl/sudoers.go → cmd/limactl/sudoers_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"errors"
"fmt"
"io"
"runtime"

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

func sudoersAction(cmd *cobra.Command, args []string) error {
if runtime.GOOS != "darwin" {
return errors.New("sudoers command is only supported on macOS right now")
}
nwCfg, err := networks.LoadConfig()
if err != nil {
return err
Expand Down
Loading