X Tutup
Skip to content

Commit 4355ba2

Browse files
committed
ctr: Add helpers to database to check Linux and ARM arch
On ARM platforms, we have to prepare the variant for spec.platform. Currently, this action would only work on Linux/ARM system. We introduce these two helpers to check running system's OS and Arch. Change-Id: Iff14087699219413779dd6caf1bf9524db1cc19e Signed-off-by: Wei Chen <Wei.Chen@arm.com>
1 parent 1a56054 commit 4355ba2

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

platforms/database.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ import (
55
"strings"
66
)
77

8+
// isLinuxOS returns true if the operating system is Linux.
9+
//
10+
// The OS value should be normalized before calling this function.
11+
func isLinuxOS(os string) bool {
12+
return os == "linux"
13+
}
14+
815
// These function are generated from from https://golang.org/src/go/build/syslist.go.
916
//
1017
// We use switch statements because they are slightly faster than map lookups
@@ -21,6 +28,17 @@ func isKnownOS(os string) bool {
2128
return false
2229
}
2330

31+
// isArmArch returns true if the architecture is ARM.
32+
//
33+
// The arch value should be normalized before being passed to this function.
34+
func isArmArch(arch string) bool {
35+
switch arch {
36+
case "arm", "arm64":
37+
return true
38+
}
39+
return false
40+
}
41+
2442
// isKnownArch returns true if we know about the architecture.
2543
//
2644
// The arch value should be normalized before being passed to this function.

0 commit comments

Comments
 (0)
X Tutup