4
4
package infoutil
5
5
6
6
import (
7
+ "errors"
8
+ "io/fs"
9
+
7
10
"github.com/lima-vm/lima/pkg/driverutil"
8
11
"github.com/lima-vm/lima/pkg/limayaml"
9
12
"github.com/lima-vm/lima/pkg/store/dirnames"
10
13
"github.com/lima-vm/lima/pkg/templatestore"
14
+ "github.com/lima-vm/lima/pkg/usrlocalsharelima"
11
15
"github.com/lima-vm/lima/pkg/version"
16
+ "github.com/sirupsen/logrus"
12
17
)
13
18
14
19
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
20
30
}
21
31
22
32
func GetInfo () (* Info , error ) {
@@ -32,6 +42,7 @@ func GetInfo() (*Info, error) {
32
42
Version : version .Version ,
33
43
DefaultTemplate : y ,
34
44
VMTypes : driverutil .Drivers (),
45
+ GuestAgents : make (map [limayaml.Arch ]GuestAgent ),
35
46
}
36
47
info .Templates , err = templatestore .Templates ()
37
48
if err != nil {
@@ -41,5 +52,19 @@ func GetInfo() (*Info, error) {
41
52
if err != nil {
42
53
return nil , err
43
54
}
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
+ }
44
69
return info , nil
45
70
}
0 commit comments