Skip to content

Commit

Permalink
pkg/usrlocalsharelima: add lima-guestagent location candidates only…
Browse files Browse the repository at this point in the history
… when `logrus.GetLevel() == logrus.DebugLevel`.

Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
  • Loading branch information
norio-nomura committed Oct 3, 2024
1 parent 644c113 commit 9c75559
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/usrlocalsharelima/usrlocalsharelima.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"runtime"

"github.com/lima-vm/lima/pkg/limayaml"
"github.com/sirupsen/logrus"
)

func Dir() (string, error) {
Expand Down Expand Up @@ -36,7 +37,6 @@ func Dir() (string, error) {
// self: /usr/local/bin/limactl
selfDir := filepath.Dir(self)
selfDirDir := filepath.Dir(selfDir)
selfDirDirDir := filepath.Dir(selfDirDir)
gaCandidates := []string{
// candidate 0:
// - self: /Applications/Lima.app/Contents/MacOS/limactl
Expand All @@ -48,12 +48,16 @@ func Dir() (string, error) {
// - agent: /usr/local/share/lima/lima-guestagent.Linux-x86_64
// - dir: /usr/local/share/lima
filepath.Join(selfDirDir, "share/lima/lima-guestagent."+ostype+"-"+arch),
// TODO: support custom path
}
if logrus.GetLevel() == logrus.DebugLevel {
// candidate 2: lauched by `~/go/bin/dlv dap`
// - self: ${workspaceFolder}/cmd/limactl/__debug_bin_XXXXXX
// - agent: ${workspaceFolder}/_output/share/lima/lima-guestagent.Linux-x86_64
// - dir: ${workspaceFolder}/_output/share/lima
filepath.Join(selfDirDirDir, "_output/share/lima/lima-guestagent."+ostype+"-"+arch),
// TODO: support custom path
candidateForDebugBuild := filepath.Join(filepath.Dir(selfDirDir), "_output/share/lima/lima-guestagent."+ostype+"-"+arch)
gaCandidates = append(gaCandidates, candidateForDebugBuild)
logrus.Infof("debug build detected, adding more guest agent candidates: %v", candidateForDebugBuild)
}
for _, gaCandidate := range gaCandidates {
if _, err := os.Stat(gaCandidate); err == nil {
Expand Down

0 comments on commit 9c75559

Please sign in to comment.