platforms: add subarchless version of Only()

`OnlyStrict()` returns a match comparer for a single platform.

Unlike `Only()`, `OnlyStrict()` does not match sub platforms.
So, "arm/vN" will not match "arm/vM" where M < N, and "amd64" will not also match "386".

`OnlyStrict()` matches non-canonical forms. So, "arm64" matches "arm/64/v8".

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
Akihiro Suda
2021-01-15 14:54:40 +09:00
parent 66fec3bbbf
commit e22ce0fa03
3 changed files with 204 additions and 0 deletions

View File

@@ -36,3 +36,8 @@ func DefaultSpec() specs.Platform {
Variant: cpuVariant,
}
}
// DefaultStrict returns strict form of Default.
func DefaultStrict() MatchComparer {
return OnlyStrict(DefaultSpec())
}