Skip to content

Commit

Permalink
allow x86_64 binaries on arm64 for darwin (#2045)
Browse files Browse the repository at this point in the history
* allow x86_64 binaries on arm64 for darwin

these binaries can run on rosetta2

Signed-off-by: sriv <srikanth.ddit@gmail.com>

* remove fmt.println used for debugging

Signed-off-by: sriv <srikanth.ddit@gmail.com>
  • Loading branch information
sriv authored Jul 14, 2021
1 parent 063444f commit 32c3dd5
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions plugin/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,19 @@ func isPlatformIndependent(zipfile string) bool {
return !re.MatchString(zipfile)
}

func isOsOSCompatible(zipfile string) bool {
func isOSCompatible(zipfile string) bool {
os := runtime.GOOS
arch := getGoArch()
if os == "darwin" && arch == "arm64" {
// darwin/arm64 can run darwin/x86_64 binaries under rosetta.
return strings.Contains(zipfile, "darwin.arm64") || strings.Contains(zipfile, "darwin.x86_64")
}
return strings.Contains(zipfile, fmt.Sprintf("%s.%s", os, arch))
}

// InstallPluginFromZipFile installs plugin from given zip file
func InstallPluginFromZipFile(zipFile string, pluginName string) InstallResult {
if !isPlatformIndependent(zipFile) && !isOsOSCompatible(zipFile) {
if !isPlatformIndependent(zipFile) && !isOSCompatible(zipFile) {
err := fmt.Errorf("provided plugin is not compatible with OS %s %s", runtime.GOOS, runtime.GOARCH)
return installError(err)
}
Expand Down

0 comments on commit 32c3dd5

Please sign in to comment.