Fix arm platform matching

The normalization was being inconsistently applied causing a
failure to match some platforms in manifest lists.
Fix the matcher and normalization to be more consistent and
add changes to parser to prevent the defaulted variants from being
set in the platform structure.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2018-06-21 16:04:03 -07:00
parent 7ff2748f9c
commit 37ab93e2c8
3 changed files with 128 additions and 10 deletions

View File

@@ -135,7 +135,7 @@ type Matcher interface {
// Applications should opt to use `Match` over directly parsing specifiers.
func NewMatcher(platform specs.Platform) Matcher {
return &matcher{
Platform: platform,
Platform: Normalize(platform),
}
}
@@ -197,6 +197,9 @@ func Parse(specifier string) (specs.Platform, error) {
}
p.Architecture, p.Variant = normalizeArch(parts[0], "")
if defaultVariant(p.Architecture, p.Variant) {
p.Variant = ""
}
if isKnownArch(p.Architecture) {
p.OS = runtime.GOOS
return p, nil
@@ -208,6 +211,9 @@ func Parse(specifier string) (specs.Platform, error) {
// about whether or not we know of the platform.
p.OS = normalizeOS(parts[0])
p.Architecture, p.Variant = normalizeArch(parts[1], "")
if defaultVariant(p.Architecture, p.Variant) {
p.Variant = ""
}
return p, nil
case 3: