Skip to content

Commit f51bf19

Browse files
committed
Add support for stable ABI windows versions
Signed-off-by: Kirtana Ashok <[email protected]>
1 parent 43a02c0 commit f51bf19

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

platforms/defaults_windows.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"strconv"
2323
"strings"
2424

25+
"github.com/Microsoft/hcsshim/osversion"
2526
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
2627
specs "github.com/opencontainers/image-spec/specs-go/v1"
2728
"golang.org/x/sys/windows"
@@ -50,14 +51,35 @@ func (m matchComparer) Match(p specs.Platform) bool {
5051
match := m.defaults.Match(p)
5152

5253
if match && p.OS == "windows" {
53-
if strings.HasPrefix(p.OSVersion, m.osVersionPrefix) {
54+
// HPC containers do not have OS version filled
55+
if p.OSVersion == "" {
5456
return true
5557
}
56-
return p.OSVersion == ""
58+
59+
hostOsVersion := getOSVersion(m.osVersionPrefix)
60+
ctrOsVersion := getOSVersion(p.OSVersion)
61+
return osversion.CheckHostAndContainerCompat(hostOsVersion, ctrOsVersion)
5762
}
5863
return false
5964
}
6065

66+
func getOSVersion(osVersionPrefix string) osversion.OSVersion {
67+
parts := strings.Split(osVersionPrefix, ".")
68+
if len(parts) < 3 {
69+
return osversion.OSVersion{}
70+
}
71+
72+
majorVersion, _ := strconv.Atoi(parts[0])
73+
minorVersion, _ := strconv.Atoi(parts[1])
74+
buildNumber, _ := strconv.Atoi(parts[2])
75+
76+
return osversion.OSVersion{
77+
MajorVersion: uint8(majorVersion),
78+
MinorVersion: uint8(minorVersion),
79+
Build: uint16(buildNumber),
80+
}
81+
}
82+
6183
// Less sorts matched platforms in front of other platforms.
6284
// For matched platforms, it puts platforms with larger revision
6385
// number in front.

0 commit comments

Comments
 (0)