vendor: github.com/containerd/platforms v0.2.1
- Remove hcsshim import from repo
    - un-exports GetOsVersion
- Update windows matcher to not compare empty os version
full diff: https://github.com/containerd/platforms/compare/v0.2.0...v0.2.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
			
			
This commit is contained in:
		
							
								
								
									
										2
									
								
								go.mod
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								go.mod
									
									
									
									
									
								
							@@ -22,7 +22,7 @@ require (
 | 
			
		||||
	github.com/containerd/imgcrypt v1.1.12-0.20240528203804-3ca09a2db5cd
 | 
			
		||||
	github.com/containerd/log v0.1.0
 | 
			
		||||
	github.com/containerd/nri v0.6.1
 | 
			
		||||
	github.com/containerd/platforms v0.2.0
 | 
			
		||||
	github.com/containerd/platforms v0.2.1
 | 
			
		||||
	github.com/containerd/plugin v0.1.0
 | 
			
		||||
	github.com/containerd/ttrpc v1.2.4
 | 
			
		||||
	github.com/containerd/typeurl/v2 v2.1.1
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								go.sum
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								go.sum
									
									
									
									
									
								
							@@ -59,8 +59,8 @@ github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
 | 
			
		||||
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
 | 
			
		||||
github.com/containerd/nri v0.6.1 h1:xSQ6elnQ4Ynidm9u49ARK9wRKHs80HCUI+bkXOxV4mA=
 | 
			
		||||
github.com/containerd/nri v0.6.1/go.mod h1:7+sX3wNx+LR7RzhjnJiUkFDhn18P5Bg/0VnJ/uXpRJM=
 | 
			
		||||
github.com/containerd/platforms v0.2.0 h1:clGNvVIcY3k39VJSYdFGohI1b3bP/eeBUVR5+XA28oo=
 | 
			
		||||
github.com/containerd/platforms v0.2.0/go.mod h1:XOM2BS6kN6gXafPLg80V6y/QUib+xoLyC3qVmHzibko=
 | 
			
		||||
github.com/containerd/platforms v0.2.1 h1:zvwtM3rz2YHPQsF2CHYM8+KtB5dvhISiXh5ZpSBQv6A=
 | 
			
		||||
github.com/containerd/platforms v0.2.1/go.mod h1:XHCb+2/hzowdiut9rkudds9bE5yJ7npe7dG/wG+uFPw=
 | 
			
		||||
github.com/containerd/plugin v0.1.0 h1:CYMyZk9beRAIe1FEKItbMLLAz/z16aXrGc+B+nv0fU4=
 | 
			
		||||
github.com/containerd/plugin v0.1.0/go.mod h1:j6HlpMtkiZMgT4UsfVNxPBUkwdw9KQGU6nCLfRxnq+w=
 | 
			
		||||
github.com/containerd/ttrpc v1.2.4 h1:eQCQK4h9dxDmpOb9QOOMh2NHTfzroH1IkmHiKZi05Oo=
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								vendor/github.com/containerd/platforms/defaults_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								vendor/github.com/containerd/platforms/defaults_windows.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -22,7 +22,6 @@ import (
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"strings"
 | 
			
		||||
 | 
			
		||||
	"github.com/Microsoft/hcsshim/osversion"
 | 
			
		||||
	specs "github.com/opencontainers/image-spec/specs-go/v1"
 | 
			
		||||
	"golang.org/x/sys/windows"
 | 
			
		||||
)
 | 
			
		||||
@@ -52,29 +51,29 @@ 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
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		hostOsVersion := GetOsVersion(m.osVersionPrefix)
 | 
			
		||||
		ctrOsVersion := GetOsVersion(p.OSVersion)
 | 
			
		||||
		return osversion.CheckHostAndContainerCompat(hostOsVersion, ctrOsVersion)
 | 
			
		||||
		hostOsVersion := getOSVersion(m.osVersionPrefix)
 | 
			
		||||
		ctrOsVersion := getOSVersion(p.OSVersion)
 | 
			
		||||
		return checkHostAndContainerCompat(hostOsVersion, ctrOsVersion)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return match
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func GetOsVersion(osVersionPrefix string) osversion.OSVersion {
 | 
			
		||||
func getOSVersion(osVersionPrefix string) osVersion {
 | 
			
		||||
	parts := strings.Split(osVersionPrefix, ".")
 | 
			
		||||
	if len(parts) < 3 {
 | 
			
		||||
		return osversion.OSVersion{}
 | 
			
		||||
		return osVersion{}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	majorVersion, _ := strconv.Atoi(parts[0])
 | 
			
		||||
	minorVersion, _ := strconv.Atoi(parts[1])
 | 
			
		||||
	buildNumber, _ := strconv.Atoi(parts[2])
 | 
			
		||||
 | 
			
		||||
	return osversion.OSVersion{
 | 
			
		||||
	return osVersion{
 | 
			
		||||
		MajorVersion: uint8(majorVersion),
 | 
			
		||||
		MinorVersion: uint8(minorVersion),
 | 
			
		||||
		Build:        uint16(buildNumber),
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										78
									
								
								vendor/github.com/containerd/platforms/platform_compat_windows.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								vendor/github.com/containerd/platforms/platform_compat_windows.go
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
			
		||||
/*
 | 
			
		||||
   Copyright The containerd Authors.
 | 
			
		||||
 | 
			
		||||
   Licensed under the Apache License, Version 2.0 (the "License");
 | 
			
		||||
   you may not use this file except in compliance with the License.
 | 
			
		||||
   You may obtain a copy of the License at
 | 
			
		||||
 | 
			
		||||
       http://www.apache.org/licenses/LICENSE-2.0
 | 
			
		||||
 | 
			
		||||
   Unless required by applicable law or agreed to in writing, software
 | 
			
		||||
   distributed under the License is distributed on an "AS IS" BASIS,
 | 
			
		||||
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
			
		||||
   See the License for the specific language governing permissions and
 | 
			
		||||
   limitations under the License.
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
package platforms
 | 
			
		||||
 | 
			
		||||
// osVersion is a wrapper for Windows version information
 | 
			
		||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
 | 
			
		||||
type osVersion struct {
 | 
			
		||||
	Version      uint32
 | 
			
		||||
	MajorVersion uint8
 | 
			
		||||
	MinorVersion uint8
 | 
			
		||||
	Build        uint16
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Windows Client and Server build numbers.
 | 
			
		||||
//
 | 
			
		||||
// See:
 | 
			
		||||
// https://learn.microsoft.com/en-us/windows/release-health/release-information
 | 
			
		||||
// https://learn.microsoft.com/en-us/windows/release-health/windows-server-release-info
 | 
			
		||||
// https://learn.microsoft.com/en-us/windows/release-health/windows11-release-information
 | 
			
		||||
const (
 | 
			
		||||
	// rs5 (version 1809, codename "Redstone 5") corresponds to Windows Server
 | 
			
		||||
	// 2019 (ltsc2019), and Windows 10 (October 2018 Update).
 | 
			
		||||
	rs5 = 17763
 | 
			
		||||
 | 
			
		||||
	// v21H2Server corresponds to Windows Server 2022 (ltsc2022).
 | 
			
		||||
	v21H2Server = 20348
 | 
			
		||||
 | 
			
		||||
	// v22H2Win11 corresponds to Windows 11 (2022 Update).
 | 
			
		||||
	v22H2Win11 = 22621
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// List of stable ABI compliant ltsc releases
 | 
			
		||||
// Note: List must be sorted in ascending order
 | 
			
		||||
var compatLTSCReleases = []uint16{
 | 
			
		||||
	v21H2Server,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CheckHostAndContainerCompat checks if given host and container
 | 
			
		||||
// OS versions are compatible.
 | 
			
		||||
// It includes support for stable ABI compliant versions as well.
 | 
			
		||||
// Every release after WS 2022 will support the previous ltsc
 | 
			
		||||
// container image. Stable ABI is in preview mode for windows 11 client.
 | 
			
		||||
// Refer: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility?tabs=windows-server-2022%2Cwindows-10#windows-server-host-os-compatibility
 | 
			
		||||
func checkHostAndContainerCompat(host, ctr osVersion) bool {
 | 
			
		||||
	// check major minor versions of host and guest
 | 
			
		||||
	if host.MajorVersion != ctr.MajorVersion ||
 | 
			
		||||
		host.MinorVersion != ctr.MinorVersion {
 | 
			
		||||
		return false
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// If host is < WS 2022, exact version match is required
 | 
			
		||||
	if host.Build < v21H2Server {
 | 
			
		||||
		return host.Build == ctr.Build
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	var supportedLtscRelease uint16
 | 
			
		||||
	for i := len(compatLTSCReleases) - 1; i >= 0; i-- {
 | 
			
		||||
		if host.Build >= compatLTSCReleases[i] {
 | 
			
		||||
			supportedLtscRelease = compatLTSCReleases[i]
 | 
			
		||||
			break
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return ctr.Build >= supportedLtscRelease && ctr.Build <= host.Build
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										2
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/modules.txt
									
									
									
									
										vendored
									
									
								
							@@ -177,7 +177,7 @@ github.com/containerd/nri/pkg/net/multiplex
 | 
			
		||||
github.com/containerd/nri/pkg/runtime-tools/generate
 | 
			
		||||
github.com/containerd/nri/pkg/stub
 | 
			
		||||
github.com/containerd/nri/types/v1
 | 
			
		||||
# github.com/containerd/platforms v0.2.0
 | 
			
		||||
# github.com/containerd/platforms v0.2.1
 | 
			
		||||
## explicit; go 1.20
 | 
			
		||||
github.com/containerd/platforms
 | 
			
		||||
# github.com/containerd/plugin v0.1.0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user