Skip to content

Commit 3a25a84

Browse files
committed
driver(registry): avoid parenthesized info while listing drivers
Signed-off-by: Ansuman Sahoo <[email protected]>
1 parent dc84c33 commit 3a25a84

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

cmd/limactl/start.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,7 @@ func createStartActionCommon(cmd *cobra.Command, _ []string) (exit bool, err err
400400
return true, err
401401
} else if listDrivers {
402402
w := cmd.OutOrStdout()
403-
for k, v := range registry.List() {
404-
if v != "internal" {
405-
_, _ = fmt.Fprintln(w, k+"(external)")
406-
continue
407-
}
403+
for k := range registry.List() {
408404
_, _ = fmt.Fprintln(w, k)
409405
}
410406
return true, nil

pkg/limainfo/limainfo.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@ type LimaInfo struct {
2222
Templates []templatestore.Template `json:"templates"`
2323
DefaultTemplate *limayaml.LimaYAML `json:"defaultTemplate"`
2424
LimaHome string `json:"limaHome"`
25-
VMTypes map[string]string `json:"vmTypes"` // since Lima v0.14.2
25+
VMTypes []string `json:"vmTypes"` // since Lima v0.14.2
26+
VMTypesEx map[string]DriverExt `json:"vmTypesEx"`
2627
GuestAgents map[limayaml.Arch]GuestAgent `json:"guestAgents"` // since Lima v1.1.0
2728
}
2829

30+
type DriverExt struct {
31+
Location string `json:"location"`
32+
}
2933
type GuestAgent struct {
3034
Location string `json:"location"` // since Lima v1.1.0
3135
}
@@ -42,10 +46,24 @@ func New() (*LimaInfo, error) {
4246
if err != nil {
4347
return nil, err
4448
}
49+
50+
reg := registry.List()
51+
if len(reg) == 0 {
52+
return nil, errors.New("no VM types found; ensure that the drivers are properly registered")
53+
}
54+
var vmTypesEx = make(map[string]DriverExt)
55+
var vmTypes []string
56+
for name, path := range reg {
57+
vmTypesEx[name] = DriverExt{
58+
Location: path,
59+
}
60+
vmTypes = append(vmTypes, name)
61+
}
4562
info := &LimaInfo{
4663
Version: version.Version,
4764
DefaultTemplate: y,
48-
VMTypes: registry.List(),
65+
VMTypes: vmTypes,
66+
VMTypesEx: vmTypesEx,
4967
GuestAgents: make(map[limayaml.Arch]GuestAgent),
5068
}
5169
info.Templates, err = templatestore.Templates()

0 commit comments

Comments
 (0)