Skip to content

Commit 4630452

Browse files
committed
driver(internal): compile vz on darwin, wsl2 on windows only and implement common error
Signed-off-by: Ansuman Sahoo <[email protected]>
1 parent 38dcc7e commit 4630452

File tree

11 files changed

+46
-246
lines changed

11 files changed

+46
-246
lines changed

cmd/limactl/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"github.com/sirupsen/logrus"
1616
"github.com/spf13/cobra"
1717

18-
_ "github.com/lima-vm/lima/pkg/builtins" // register built-in drivers
1918
"github.com/lima-vm/lima/pkg/debugutil"
19+
_ "github.com/lima-vm/lima/pkg/driver/qemu" // register qemu driver for all platforms
2020
"github.com/lima-vm/lima/pkg/fsutil"
2121
"github.com/lima-vm/lima/pkg/osutil"
2222
"github.com/lima-vm/lima/pkg/store/dirnames"

cmd/limactl/main_darwin.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build darwin && !no_vz
2+
3+
// SPDX-FileCopyrightText: Copyright The Lima Authors
4+
// SPDX-License-Identifier: Apache-2.0
5+
6+
package main
7+
8+
// Import vz driver to register it in the registry on darwin.
9+
import _ "github.com/lima-vm/lima/pkg/driver/vz"

cmd/limactl/main_windows.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//go:build windows && !no_wsl
2+
3+
// SPDX-FileCopyrightText: Copyright The Lima Authors
4+
// SPDX-License-Identifier: Apache-2.0
5+
6+
package main
7+
8+
// Import wsl2 driver to register it in the registry on windows.
9+
import _ "github.com/lima-vm/lima/pkg/driver/wsl2"

pkg/driver/vz/errors_darwin.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ package vz
88
import "errors"
99

1010
//nolint:revive,staticcheck // false positives with proper nouns
11-
var errRosettaUnsupported = errors.New("Rosetta is unsupported on non-ARM64 hosts")
11+
var (
12+
errRosettaUnsupported = errors.New("Rosetta is unsupported on non-ARM64 hosts")
13+
errUnimplemented = errors.New("unimplemented")
14+
)

pkg/driver/vz/register.go

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

pkg/driver/vz/vz_driver_darwin.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,19 +286,19 @@ func (l *LimaVzDriver) GetDisplayConnection(_ context.Context) (string, error) {
286286
}
287287

288288
func (l *LimaVzDriver) CreateSnapshot(_ context.Context, _ string) error {
289-
return errors.New("unimplemented")
289+
return errUnimplemented
290290
}
291291

292292
func (l *LimaVzDriver) ApplySnapshot(_ context.Context, _ string) error {
293-
return errors.New("unimplemented")
293+
return errUnimplemented
294294
}
295295

296296
func (l *LimaVzDriver) DeleteSnapshot(_ context.Context, _ string) error {
297-
return errors.New("unimplemented")
297+
return errUnimplemented
298298
}
299299

300300
func (l *LimaVzDriver) ListSnapshots(_ context.Context) (string, error) {
301-
return "", errors.New("unimplemented")
301+
return "", errUnimplemented
302302
}
303303

304304
func (l *LimaVzDriver) ForwardGuestAgent() bool {

pkg/driver/vz/vz_driver_others.go

Lines changed: 0 additions & 118 deletions
This file was deleted.

pkg/driver/wsl2/errors_windows.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//go:build windows && !no_wsl
2+
3+
// SPDX-FileCopyrightText: Copyright The Lima Authors
4+
// SPDX-License-Identifier: Apache-2.0
5+
6+
package wsl2
7+
8+
import "errors"
9+
10+
//nolint:revive,staticcheck // false positives with proper nouns
11+
var errUnimplemented = errors.New("unimplemented")

pkg/driver/wsl2/register.go

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

pkg/driver/wsl2/wsl_driver_others.go

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)