Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit 391bb00

Browse files
authored
feat: ARM-arch is now supported, avoid always recomputing values (#48)
1 parent 44ce7f9 commit 391bb00

File tree

1 file changed

+24
-17
lines changed
  • core/src/main/java/io/javaoperatorsdk/jenvtest/binary

1 file changed

+24
-17
lines changed
Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,37 @@
11
package io.javaoperatorsdk.jenvtest.binary;
22

33
public class OSInfo {
4+
private final String os;
5+
private final String arch;
46

5-
public String getOSName() {
6-
String os = System.getProperty("os.name").toLowerCase();
7+
public OSInfo() {
8+
final var osArch = System.getProperty("os.arch").toLowerCase();
9+
switch (osArch) {
10+
case "ppc64":
11+
arch = "ppc64le";
12+
break;
13+
case "aarch64":
14+
arch = "arm64";
15+
break;
16+
default:
17+
arch = "amd64";
18+
}
19+
20+
final var os = System.getProperty("os.name").toLowerCase();
721
if (os.contains("win")) {
8-
return "windows";
22+
this.os = "windows";
923
} else if (os.contains("mac")) {
10-
return "darwin";
24+
this.os = "darwin";
1125
} else {
12-
return os;
26+
this.os = os;
1327
}
1428
}
1529

16-
/**
17-
* Only amd64 and ppc64 binaries available.
18-
*
19-
* @return ppc64le if on that architecture otherwise amd64.
20-
*/
21-
public String getOSArch() {
22-
var osArch = System.getProperty("os.arch").toLowerCase();
23-
if (osArch.contains("ppc64")) {
24-
return "ppc64le";
25-
} else {
26-
return "amd64";
27-
}
30+
public String getOSName() {
31+
return os;
2832
}
2933

34+
public String getOSArch() {
35+
return arch;
36+
}
3037
}

0 commit comments

Comments
 (0)