Skip to content

Commit

Permalink
Merge pull request #135 from ioito/hotfix/qx-win-version
Browse files Browse the repository at this point in the history
fix: identify the windows version
  • Loading branch information
ioito authored Aug 26, 2024
2 parents 0163ba9 + d627ecb commit ac73b70
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 16 additions & 0 deletions util/imagetools/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ func TestNormalizeImageInfo(t *testing.T) {
OsLang: "",
OsArch: "x86_64",
},
{
Name: "Template-Win8",
OsDistro: "Windows",
OsType: osprofile.OS_TYPE_WINDOWS,
OsVersion: "8",
OsLang: "",
OsArch: "x86_64",
},
{
Name: "Template-Win2019",
OsDistro: "Windows Server",
OsType: osprofile.OS_TYPE_WINDOWS,
OsVersion: "2019",
OsLang: "",
OsArch: "x86_64",
},
}

for _, image := range images {
Expand Down
7 changes: 6 additions & 1 deletion util/imagetools/imagetools.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func normalizeOsDistribution(osDist string, imageName string) string {
return OS_DIST_KYLIN
} else if strings.Contains(osDist, "uos") {
return OS_DIST_UOS
} else if strings.Contains(osDist, "windows") {
} else if strings.Contains(osDist, "windows") || regexp.MustCompile(".+win(xp|7|8|10|11|2003|2008|2012|2016|2019|2022)*").MatchString(osDist) {
for _, ver := range []string{"2003", "2008", "2012", "2016", "2019", "2022"} {
if strings.Contains(osDist, ver) {
return OS_DIST_WINDOWS_SERVER
Expand Down Expand Up @@ -218,6 +218,11 @@ func normalizeOsVersion(imageName string, osDist string, osVersion string) strin
}
}
}
for i := len(versions) - 1; i > 0; i-- {
if strings.Contains(imageName, versions[i]) {
return versions[i]
}
}
}
return ""
}
Expand Down

0 comments on commit ac73b70

Please sign in to comment.