Skip to content

Commit 703fe64

Browse files
committed
Move GuestAgentBinary to usrlocalsharelima
Signed-off-by: Anders F Björklund <[email protected]>
1 parent bfd7471 commit 703fe64

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

Diff for: pkg/cidata/cidata.go

+7-18
Original file line numberDiff line numberDiff line change
@@ -336,14 +336,18 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort
336336
}
337337
}
338338

339-
guestAgentBinary, err := GuestAgentBinary(*y.OS, *y.Arch)
339+
guestAgentBinary, err := usrlocalsharelima.GuestAgentBinary(*y.OS, *y.Arch)
340340
if err != nil {
341341
return err
342342
}
343-
defer guestAgentBinary.Close()
343+
guestAgent, err := os.Open(guestAgentBinary)
344+
if err != nil {
345+
return err
346+
}
347+
defer guestAgent.Close()
344348
layout = append(layout, iso9660util.Entry{
345349
Path: "lima-guestagent",
346-
Reader: guestAgentBinary,
350+
Reader: guestAgent,
347351
})
348352

349353
if nerdctlArchive != "" {
@@ -370,21 +374,6 @@ func GenerateISO9660(instDir, name string, y *limayaml.LimaYAML, udpDNSLocalPort
370374
return iso9660util.Write(filepath.Join(instDir, filenames.CIDataISO), "cidata", layout)
371375
}
372376

373-
func GuestAgentBinary(ostype limayaml.OS, arch limayaml.Arch) (io.ReadCloser, error) {
374-
if ostype == "" {
375-
return nil, errors.New("os must be set")
376-
}
377-
if arch == "" {
378-
return nil, errors.New("arch must be set")
379-
}
380-
dir, err := usrlocalsharelima.Dir()
381-
if err != nil {
382-
return nil, err
383-
}
384-
gaPath := filepath.Join(dir, "lima-guestagent."+ostype+"-"+arch)
385-
return os.Open(gaPath)
386-
}
387-
388377
func getCert(content string) Cert {
389378
lines := []string{}
390379
for _, line := range strings.Split(content, "\n") {

Diff for: pkg/usrlocalsharelima/usrlocalsharelima.go

+14
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,17 @@ func Dir() (string, error) {
6060
return "", fmt.Errorf("failed to find \"lima-guestagent.%s-%s\" binary for %q, attempted %v",
6161
ostype, arch, self, gaCandidates)
6262
}
63+
64+
func GuestAgentBinary(ostype limayaml.OS, arch limayaml.Arch) (string, error) {
65+
if ostype == "" {
66+
return "", errors.New("os must be set")
67+
}
68+
if arch == "" {
69+
return "", errors.New("arch must be set")
70+
}
71+
dir, err := Dir()
72+
if err != nil {
73+
return "", err
74+
}
75+
return filepath.Join(dir, "lima-guestagent."+ostype+"-"+arch), nil
76+
}

0 commit comments

Comments
 (0)