Skip to content

Commit

Permalink
macos: Improve TrayExecutablePath construction
Browse files Browse the repository at this point in the history
The code is calling InstallPath() even on crc versions where it was not
set at build time. Since InstallPath() is printing a warning when this
occurs, it's better if we can avoid this.
This commit adds a fallback to set TrayExecutablePath to
`~/.crc/bin/CodeReady Containers` in such scenarios.
  • Loading branch information
cfergeau authored and praveenkumar committed Aug 26, 2021
1 parent f63efba commit 299226b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion pkg/crc/constants/constants_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ const (
)

var (
TrayExecutablePath = filepath.Clean(filepath.Join(version.InstallPath(), "..", "MacOS", "CodeReady Containers"))
TapSocketPath = filepath.Join(CrcBaseDir, "tap.sock")
DaemonHTTPSocketPath = filepath.Join(CrcBaseDir, "crc-http.sock")
)

func TrayExecutablePath() string {
if version.IsInstaller() {
return filepath.Clean(filepath.Join(version.InstallPath(), "..", "MacOS", "CodeReady Containers"))
}
// Should not be reached, tray is only supported on installer builds
return filepath.Clean(filepath.Join(BinDir(), "CodeReady Containers"))
}
2 changes: 1 addition & 1 deletion pkg/crc/preflight/preflight_checks_tray_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func getTrayConfig() (*launchd.AgentConfig, error) {

trayConfig := launchd.AgentConfig{
Label: trayAgentLabel,
ExecutablePath: constants.TrayExecutablePath,
ExecutablePath: constants.TrayExecutablePath(),
StdOutFilePath: stdOutFilePathTray,
}

Expand Down

0 comments on commit 299226b

Please sign in to comment.