Skip to content

Commit 371198f

Browse files
committed
Managed network support is only available on macOS right now
Signed-off-by: Jan Dubois <[email protected]>
1 parent 07e6823 commit 371198f

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

cmd/limactl/sudoers.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,33 @@ package main
33
import (
44
"errors"
55
"fmt"
6+
"runtime"
7+
68
"github.com/lima-vm/lima/pkg/networks"
79
"github.com/spf13/cobra"
810
)
911

1012
func newSudoersCommand() *cobra.Command {
1113
sudoersCommand := &cobra.Command{
12-
Use: "sudoers [SUDOERSFILE]",
13-
Short: "Generate /etc/sudoers.d/lima file.",
14-
Args: cobra.MaximumNArgs(1),
15-
RunE: sudoersAction,
14+
Use: "sudoers [SUDOERSFILE]",
15+
Short: "Generate /etc/sudoers.d/lima file.",
16+
Args: cobra.MaximumNArgs(1),
17+
RunE: sudoersAction,
1618
}
1719
sudoersCommand.Flags().Bool("check", false,
1820
"check that the sudoers file is up-to-date with $LIMA_HOME/_config/networks.yaml")
1921
return sudoersCommand
2022
}
2123

2224
func sudoersAction(cmd *cobra.Command, args []string) error {
25+
if runtime.GOOS != "darwin" {
26+
return errors.New("sudoers command is only supported on macOS right now")
27+
}
2328
check, err := cmd.Flags().GetBool("check")
2429
if err != nil {
2530
return err
2631
}
27-
if check {
32+
if check {
2833
var file string
2934
switch len(args) {
3035
case 0:

pkg/limayaml/validate.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ func validateNetwork(y LimaYAML) error {
179179
for i, nw := range y.Networks {
180180
field := fmt.Sprintf("networks[%d]", i)
181181
if nw.Lima != "" {
182+
if runtime.GOOS != "darwin" {
183+
return fmt.Errorf("field `%s.lima` is only supported on macOS right now", field)
184+
}
182185
if nw.VNL != "" {
183186
return fmt.Errorf("field `%s.lima` and field `%s.vnl` are mutually exclusive", field, field)
184187
}

pkg/networks/config.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"gopkg.in/yaml.v2"
88
"os"
99
"path/filepath"
10+
"runtime"
1011
"sync"
1112

1213
"github.com/lima-vm/lima/pkg/store"
@@ -60,8 +61,11 @@ func load() {
6061

6162
// Config returns the network config from the _config/networks.yaml file.
6263
func Config() (NetworksConfig, error) {
63-
load()
64-
return cache.config, cache.err
64+
if runtime.GOOS == "darwin" {
65+
load()
66+
return cache.config, cache.err
67+
}
68+
return NetworksConfig{}, errors.New("networks.yaml configuration is only supported on macOS right now")
6569
}
6670

6771
func VDESock(name string) (string, error) {

pkg/networks/reconcile.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"os"
88
"os/exec"
9+
"runtime"
910
"strings"
1011
"sync"
1112

@@ -14,6 +15,9 @@ import (
1415
)
1516

1617
func Reconcile(ctx context.Context, newInst string) error {
18+
if runtime.GOOS != "darwin" {
19+
return nil
20+
}
1721
config, err := Config()
1822
if err != nil {
1923
return err

0 commit comments

Comments
 (0)