Derive cpuinfo as needed, instead of at init-time

This changes platforms.Parse to hit /proc to look up CPU info only when
it's needed, instead of in init(). This makes the package a bit easier
for other packages to consume, especially clients that don't call
platforms.Parse or need to lookup CPU info.

Signed-off-by: Jason Hall <jasonhall@redhat.com>
This commit is contained in:
Jason Hall
2021-01-19 13:50:14 -05:00
parent 66fec3bbbf
commit 363f2c392c
5 changed files with 18 additions and 13 deletions

View File

@@ -31,8 +31,8 @@ func TestParseSelector(t *testing.T) {
defaultVariant = ""
)
if defaultArch == "arm" && cpuVariant != "v7" {
defaultVariant = cpuVariant
if defaultArch == "arm" && cpuVariant() != "v7" {
defaultVariant = cpuVariant()
}
for _, testcase := range []struct {