Skip to content

Commit a047e65

Browse files
committed
limactl info: show the detected guest agent paths
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 3d36eb1 commit a047e65

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

pkg/infoutil/infoutil.go

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,29 @@
44
package infoutil
55

66
import (
7+
"errors"
8+
"io/fs"
9+
710
"github.com/lima-vm/lima/pkg/driverutil"
811
"github.com/lima-vm/lima/pkg/limayaml"
912
"github.com/lima-vm/lima/pkg/store/dirnames"
1013
"github.com/lima-vm/lima/pkg/templatestore"
14+
"github.com/lima-vm/lima/pkg/usrlocalsharelima"
1115
"github.com/lima-vm/lima/pkg/version"
16+
"github.com/sirupsen/logrus"
1217
)
1318

1419
type Info struct {
15-
Version string `json:"version"`
16-
Templates []templatestore.Template `json:"templates"`
17-
DefaultTemplate *limayaml.LimaYAML `json:"defaultTemplate"`
18-
LimaHome string `json:"limaHome"`
19-
VMTypes []string `json:"vmTypes"` // since Lima v0.14.2
20+
Version string `json:"version"`
21+
Templates []templatestore.Template `json:"templates"`
22+
DefaultTemplate *limayaml.LimaYAML `json:"defaultTemplate"`
23+
LimaHome string `json:"limaHome"`
24+
VMTypes []string `json:"vmTypes"` // since Lima v0.14.2
25+
GuestAgents map[limayaml.Arch]GuestAgent `json:"guestAgents"` // since Lima v1.1.0
26+
}
27+
28+
type GuestAgent struct {
29+
Location string `json:"location"` // since Lima v1.1.0
2030
}
2131

2232
func GetInfo() (*Info, error) {
@@ -32,6 +42,7 @@ func GetInfo() (*Info, error) {
3242
Version: version.Version,
3343
DefaultTemplate: y,
3444
VMTypes: driverutil.Drivers(),
45+
GuestAgents: make(map[limayaml.Arch]GuestAgent),
3546
}
3647
info.Templates, err = templatestore.Templates()
3748
if err != nil {
@@ -41,5 +52,19 @@ func GetInfo() (*Info, error) {
4152
if err != nil {
4253
return nil, err
4354
}
55+
for _, arch := range limayaml.ArchTypes {
56+
bin, err := usrlocalsharelima.GuestAgentBinary(limayaml.LINUX, arch)
57+
if err != nil {
58+
if errors.Is(err, fs.ErrNotExist) {
59+
logrus.WithError(err).Debugf("Failed to resolve the guest agent binary for %q", arch)
60+
} else {
61+
logrus.WithError(err).Warnf("Failed to resolve the guest agent binary for %q", arch)
62+
}
63+
continue
64+
}
65+
info.GuestAgents[arch] = GuestAgent{
66+
Location: bin,
67+
}
68+
}
4469
return info, nil
4570
}

0 commit comments

Comments
 (0)