Skip to content

Commit e53a368

Browse files
committed
driver(internal): compile vz on darwin, wsl2 on windows only and implement common error
Signed-off-by: Ansuman Sahoo <anshumansahoo500@gmail.com>
1 parent 1c526cb commit e53a368

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
@@ -11,8 +11,8 @@ import (
1111
"runtime"
1212
"strings"
1313

14-
_ "github.com/lima-vm/lima/pkg/builtins" // register built-in drivers
1514
"github.com/lima-vm/lima/pkg/debugutil"
15+
_ "github.com/lima-vm/lima/pkg/driver/qemu" // register qemu driver for all platforms
1616
"github.com/lima-vm/lima/pkg/fsutil"
1717
"github.com/lima-vm/lima/pkg/osutil"
1818
"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
@@ -287,19 +287,19 @@ func (l *LimaVzDriver) GetDisplayConnection(_ context.Context) (string, error) {
287287
}
288288

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

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

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

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

305305
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.

pkg/driver/wsl2/wsl_driver_windows.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,19 +246,19 @@ func (l *LimaWslDriver) GetDisplayConnection(_ context.Context) (string, error)
246246
}
247247

248248
func (l *LimaWslDriver) CreateSnapshot(_ context.Context, _ string) error {
249-
return fmt.Errorf("unimplemented")
249+
return errUnimplemented
250250
}
251251

252252
func (l *LimaWslDriver) ApplySnapshot(_ context.Context, _ string) error {
253-
return fmt.Errorf("unimplemented")
253+
return errUnimplemented
254254
}
255255

256256
func (l *LimaWslDriver) DeleteSnapshot(_ context.Context, _ string) error {
257-
return fmt.Errorf("unimplemented")
257+
return errUnimplemented
258258
}
259259

260260
func (l *LimaWslDriver) ListSnapshots(_ context.Context) (string, error) {
261-
return "", fmt.Errorf("unimplemented")
261+
return "", errUnimplemented
262262
}
263263

264264
func (l *LimaWslDriver) ForwardGuestAgent() bool {

0 commit comments

Comments
 (0)