feat(amazon): support amazon linux 2022 (#1338)

This commit is contained in:
MaineK00n
2021-12-09 11:06:44 +09:00
committed by GitHub
parent 0c6a892893
commit 2b7294a504
8 changed files with 61 additions and 33 deletions

View File

@@ -301,10 +301,7 @@ func (l Distro) String() string {
// MajorVersion returns Major version
func (l Distro) MajorVersion() (int, error) {
if l.Family == constant.Amazon {
if isAmazonLinux1(l.Release) {
return 1, nil
}
return 2, nil
return strconv.Atoi(getAmazonLinuxVersion(l.Release))
}
if 0 < len(l.Release) {
return strconv.Atoi(strings.Split(l.Release, ".")[0])

View File

@@ -70,6 +70,13 @@ func TestDistro_MajorVersion(t *testing.T) {
in Distro
out int
}{
{
in: Distro{
Family: Amazon,
Release: "2022 (Amazon Linux)",
},
out: 2022,
},
{
in: Distro{
Family: Amazon,

View File

@@ -39,14 +39,11 @@ func (e EOL) IsExtendedSuppportEnded(now time.Time) bool {
func GetEOL(family, release string) (eol EOL, found bool) {
switch family {
case constant.Amazon:
rel := "2"
if isAmazonLinux1(release) {
rel = "1"
}
eol, found = map[string]EOL{
"1": {StandardSupportUntil: time.Date(2023, 6, 30, 23, 59, 59, 0, time.UTC)},
"2": {},
}[rel]
"1": {StandardSupportUntil: time.Date(2023, 6, 30, 23, 59, 59, 0, time.UTC)},
"2": {},
"2022": {},
}[getAmazonLinuxVersion(release)]
case constant.RedHat:
// https://access.redhat.com/support/policy/updates/errata
eol, found = map[string]EOL{
@@ -206,6 +203,10 @@ func majorDotMinor(osVer string) (majorDotMinor string) {
return fmt.Sprintf("%s.%s", ss[0], ss[1])
}
func isAmazonLinux1(osRelease string) bool {
return len(strings.Fields(osRelease)) == 1
func getAmazonLinuxVersion(osRelease string) string {
ss := strings.Fields(osRelease)
if len(ss) == 1 {
return "1"
}
return ss[0]
}

View File

@@ -45,6 +45,14 @@ func TestEOL_IsStandardSupportEnded(t *testing.T) {
extEnded: false,
found: true,
},
{
name: "amazon linux 2022 supported",
fields: fields{family: Amazon, release: "2022 (Amazon Linux)"},
now: time.Date(2023, 7, 1, 23, 59, 59, 0, time.UTC),
stdEnded: false,
extEnded: false,
found: true,
},
//RHEL
{
name: "RHEL7 supported",