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
25 changes: 23 additions & 2 deletions compare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ func TestOnly(t *testing.T) {
{
platform: "windows/amd64",
matches: map[bool][]string{
true: {"windows/amd64"},
true: {
"windows/amd64",
"windows(10.0.17763)/amd64",
},
false: {
"linux/amd64",
"linux/arm/v7",
Expand Down Expand Up @@ -265,7 +268,25 @@ func TestOnlyStrict(t *testing.T) {
{
platform: "windows/amd64",
matches: map[bool][]string{
true: {"windows/amd64"},
true: {
"windows/amd64",
"windows(10.0.17763)/amd64",
},
false: {
"linux/amd64",
"linux/arm/v7",
"linux/arm64",
"windows/arm",
},
},
},
{
platform: "windows(10.0.17763)/amd64",
matches: map[bool][]string{
true: {
"windows/amd64",
"windows(10.0.17763)/amd64",
},
false: {
"linux/amd64",
"linux/arm/v7",
Expand Down
2 changes: 1 addition & 1 deletion defaults_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (m windowsmatcher) Match(p specs.Platform) bool {

if match && m.OS == "windows" {
// HPC containers do not have OS version filled
if p.OSVersion == "" {
if m.OSVersion == "" || p.OSVersion == "" {
return true
}

Expand Down
20 changes: 20 additions & 0 deletions defaults_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@ func TestMatchComparerMatch_WCOW(t *testing.T) {
// TestMatchComparerMatch_ABICheckWCOW checks windows platform matcher
// behavior for stable ABI and non-stable ABI compliant versions
func TestMatchComparerMatch_ABICheckWCOW(t *testing.T) {
platformNoVersion := imagespec.Platform{
Architecture: "amd64",
OS: "windows",
}
platformWS2019 := imagespec.Platform{
Architecture: "amd64",
OS: "windows",
Expand All @@ -160,6 +164,7 @@ func TestMatchComparerMatch_ABICheckWCOW(t *testing.T) {
OS: "windows",
OSVersion: "10.0.22621",
}
matcherNoVersion := NewMatcher(platformNoVersion).(windowsmatcher)
matcherWS2019 := windowsmatcher{
Platform: platformWS2019,
osVersionPrefix: platformWS2019.OSVersion,
Expand Down Expand Up @@ -241,6 +246,21 @@ func TestMatchComparerMatch_ABICheckWCOW(t *testing.T) {
},
match: true,
},
{
hostPlatformMatcher: matcherNoVersion,
testPlatform: platformWS2019,
match: true,
},
{
hostPlatformMatcher: matcherNoVersion,
testPlatform: platformNoVersion,
match: true,
},
{
hostPlatformMatcher: matcherNoVersion,
testPlatform: platformWindows11,
match: true,
},
} {
assert.Equal(t, test.match, test.hostPlatformMatcher.Match(test.testPlatform), "should match: %t, %s to %s", test.match, test.hostPlatformMatcher.Platform, test.testPlatform)
}
Expand Down