Skip to content

Commit 93d4235

Browse files
authored
Merge pull request #4274 from afbjorklund/guest-install-gzip
Handle compressed guestagent binary
2 parents e14ee7b + 84f8b3c commit 93d4235

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

cmd/limactl/guest-install.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import (
77
"bytes"
88
"compress/gzip"
99
"context"
10-
"errors"
1110
"fmt"
1211
"io"
1312
"os"
1413
"os/exec"
1514
"path/filepath"
15+
"strings"
1616

1717
"github.com/sirupsen/logrus"
1818
"github.com/spf13/cobra"
@@ -86,11 +86,8 @@ func guestInstallAction(cmd *cobra.Command, args []string) error {
8686
return err
8787
}
8888
guestAgentFilename := filepath.Base(guestAgentBinary)
89-
if _, err := os.Stat(guestAgentBinary); err != nil {
90-
if !errors.Is(err, os.ErrNotExist) {
91-
return err
92-
}
93-
compressedGuestAgent, err := os.Open(guestAgentBinary + ".gz")
89+
if filepath.Ext(guestAgentBinary) == ".gz" {
90+
compressedGuestAgent, err := os.Open(guestAgentBinary)
9491
if err != nil {
9592
return err
9693
}
@@ -99,7 +96,7 @@ func guestInstallAction(cmd *cobra.Command, args []string) error {
9996
if err != nil {
10097
return err
10198
}
102-
logrus.Debugf("Decompressing %s.gz", guestAgentBinary)
99+
logrus.Debugf("Decompressing %s", guestAgentBinary)
103100
guestAgent, err := gzip.NewReader(compressedGuestAgent)
104101
if err != nil {
105102
return err
@@ -112,6 +109,7 @@ func guestInstallAction(cmd *cobra.Command, args []string) error {
112109
tmpGuestAgent.Close()
113110
guestAgentBinary = tmpGuestAgent.Name()
114111
defer os.RemoveAll(guestAgentBinary)
112+
guestAgentFilename = strings.TrimSuffix(guestAgentFilename, ".gz")
115113
}
116114
tmpname := "lima-guestagent"
117115
tmp, err := shell(ctx, sshExe, sshFlags, hostname, "mktemp", "-t", "lima-guestagent.XXXXXX")

0 commit comments

Comments
 (0)