Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions platform_windows_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package platforms

import (
"slices"
"strconv"
"strings"

Expand Down Expand Up @@ -162,3 +163,14 @@ func (c *windowsMatchComparer) Less(p1, p2 specs.Platform) bool {
}
return m1 && !m2
}

type windowsStripFeaturesMatcher struct {
Matcher
}

func (m windowsStripFeaturesMatcher) Match(p specs.Platform) bool {
if i := slices.Index(p.OSFeatures, "win32k"); i >= 0 {
p.OSFeatures = slices.Delete(slices.Clone(p.OSFeatures), i, i+1)
}
return m.Matcher.Match(p)
}
8 changes: 7 additions & 1 deletion platforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ func NewMatcher(platform specs.Platform) Matcher {
m.osvM = &windowsVersionMatcher{
windowsOSVersion: getWindowsOSVersion(platform.OSVersion),
}

// In prior versions, the win32k os feature was not considered for matching,
// strip out the win32k feature for comparison
var stripped Matcher = windowsStripFeaturesMatcher{m}

// In prior versions, on windows, the returned matcher implements a
// MatchComprarer interface.
// This preserves that behavior for backwards compatibility.
Expand All @@ -165,8 +170,9 @@ func NewMatcher(platform specs.Platform) Matcher {
// It was likely intended to be used in `Ordered` but it is not since
// `Less` that is implemented here ends up getting masked due to wrapping.
if runtime.GOOS == "windows" {
return &windowsMatchComparer{m}
return &windowsMatchComparer{stripped}
}
return stripped
}
return m
}
Expand Down
Loading