New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow containerd on Windows 11 to use Windows Server 2022 images #8137
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,24 @@ package platforms | |
|
||
import ( | ||
specs "github.com/opencontainers/image-spec/specs-go/v1" | ||
"golang.org/x/sys/windows/registry" | ||
) | ||
|
||
func isClientOS() bool { | ||
k, err := registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\Microsoft\Windows NT\CurrentVersion`, registry.QUERY_VALUE) | ||
if err != nil { | ||
return false | ||
} | ||
defer k.Close() | ||
|
||
installationType, _, err := k.GetStringValue("InstallationType") | ||
if err != nil { | ||
return false | ||
} | ||
|
||
return installationType == "Client" | ||
} | ||
Comment on lines
+24
to
+37
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @thaJeztah Thinking on your comment, this kind of feels like it could be a helper in hcsshim/osversion also.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kevpar Curious on your thoughts. This regkey approach was recommended (6 years ago however) at least as an alternative to GetProductInfo: https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/ee391629(v=vs.85) |
||
|
||
// NewMatcher returns a Windows matcher that will match on osVersionPrefix if | ||
// the platform is Windows otherwise use the default matcher | ||
func newDefaultMatcher(platform specs.Platform) Matcher { | ||
|
@@ -30,5 +46,6 @@ func newDefaultMatcher(platform specs.Platform) Matcher { | |
defaultMatcher: &matcher{ | ||
Platform: Normalize(platform), | ||
}, | ||
isClientOS: isClientOS(), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already indirectly import a package for version parsing (go.mod, vendor). Should we just reuse it instead of maintaining a pretty fragile logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, what this is parsing isn't semver (it's Windows 4-part OS versions like 10.0.20348.1850), so from what I can tell, that library won't actually parse them correctly. 😅