From 8b575a6198b42a87ae75cd9c2842de37bc5d1a5e Mon Sep 17 00:00:00 2001 From: Qu Xuan Date: Wed, 13 Nov 2019 14:46:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=81=BF=E5=85=8D=E5=8C=B9=E9=85=8D?= =?UTF-8?q?=E5=88=B064=E5=AF=BC=E8=87=B4version=E6=98=AF6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/util/imagetools/image_test.go | 6 ++++++ pkg/util/imagetools/imagetools.go | 14 +++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pkg/util/imagetools/image_test.go b/pkg/util/imagetools/image_test.go index 3437a51304..d58dfe1239 100644 --- a/pkg/util/imagetools/image_test.go +++ b/pkg/util/imagetools/image_test.go @@ -47,6 +47,12 @@ func TestNormalizeImageInfo(t *testing.T) { OsType: "linux", OsVersion: "14", }, + { + Name: "CentOS 7.2 64位", + OsDistro: "CentOS", + OsType: "linux", + OsVersion: "7", + }, } for _, image := range images { diff --git a/pkg/util/imagetools/imagetools.go b/pkg/util/imagetools/imagetools.go index 568ad114fe..0ca200dfa0 100644 --- a/pkg/util/imagetools/imagetools.go +++ b/pkg/util/imagetools/imagetools.go @@ -70,6 +70,8 @@ func normalizeOsDistribution(osDist string, imageName string) string { return "Aliyun" } else if strings.Contains(osDist, "freebsd") { return "FreeBSD" + } else if strings.Contains(osDist, "euleros") { + return "EulerOS" } else if strings.Contains(osDist, "windows") { if strings.Contains(osDist, "2003") { return "Windows Server 2003" @@ -89,13 +91,14 @@ func normalizeOsDistribution(osDist string, imageName string) string { var imageVersions = map[string][]string{ "CentOS": {"5", "6", "7"}, - "RHEL": {"5", "6", "7"}, - "FreeBSD": {"10"}, - "Ubuntu": {"10", "12", "14", "16", "18"}, + "RHEL": {"5", "6", "7", "8"}, + "FreeBSD": {"10", "11", "12"}, + "Ubuntu": {"10", "12", "14", "16", "18", "19"}, "OpenSUSE": {"11", "12"}, "SUSE": {"10", "11", "12", "13"}, - "Debian": {"6", "7", "8", "9"}, + "Debian": {"6", "7", "8", "9", "10"}, "CoreOS": {"7"}, + "EulerOS": {"2"}, "Aliyun": {}, } @@ -107,7 +110,8 @@ func normalizeOsVersion(imageName string, osDist string, osVersion string) strin return version } } else { - if strings.Contains(imageName, " "+version) || strings.Contains(imageName, "_"+version) { + imageName = strings.Replace(imageName, "64", "", -1) + if strings.Contains(imageName, " "+version) || strings.Contains(imageName, "_"+version) || strings.Contains(imageName, "-"+version) { return version } }