Skip to content

Commit adbf321

Browse files
committed
Strip the win32k when comparing windows platforms
Previously win32k was not considered when comparing Windows platforms, leading a failure to match against some existing images. Signed-off-by: Derek McGowan <[email protected]>
1 parent e543b9f commit adbf321

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

platform_windows_compat.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package platforms
1818

1919
import (
20+
"slices"
2021
"strconv"
2122
"strings"
2223

@@ -162,3 +163,14 @@ func (c *windowsMatchComparer) Less(p1, p2 specs.Platform) bool {
162163
}
163164
return m1 && !m2
164165
}
166+
167+
type windowsStripFeaturesMatcher struct {
168+
Matcher
169+
}
170+
171+
func (m windowsStripFeaturesMatcher) Match(p specs.Platform) bool {
172+
if i := slices.Index(p.OSFeatures, "win32k"); i >= 0 {
173+
p.OSFeatures = slices.Delete(slices.Clone(p.OSFeatures), i, i+1)
174+
}
175+
return m.Matcher.Match(p)
176+
}

platforms.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ func NewMatcher(platform specs.Platform) Matcher {
156156
m.osvM = &windowsVersionMatcher{
157157
windowsOSVersion: getWindowsOSVersion(platform.OSVersion),
158158
}
159+
160+
// In prior versions, the win32k os feature was not considered for matching,
161+
// strip out the win32k feature for comparison
162+
var stripped Matcher = windowsStripFeaturesMatcher{m}
163+
159164
// In prior versions, on windows, the returned matcher implements a
160165
// MatchComprarer interface.
161166
// This preserves that behavior for backwards compatibility.
@@ -165,8 +170,9 @@ func NewMatcher(platform specs.Platform) Matcher {
165170
// It was likely intended to be used in `Ordered` but it is not since
166171
// `Less` that is implemented here ends up getting masked due to wrapping.
167172
if runtime.GOOS == "windows" {
168-
return &windowsMatchComparer{m}
173+
return &windowsMatchComparer{stripped}
169174
}
175+
return stripped
170176
}
171177
return m
172178
}

0 commit comments

Comments
 (0)