Merge pull request #721 from UiPath/new-os-distributions

Add support for SLES, Oracle and Amazon Linux
This commit is contained in:
Kubernetes Prow Robot
2023-01-31 10:48:56 -08:00
committed by GitHub
5 changed files with 60 additions and 0 deletions

View File

@@ -58,6 +58,12 @@ func getOSVersion(osReleasePath string) (string, error) {
return getDebianVersion(osReleaseMap), nil
case "rhel":
return getDebianVersion(osReleaseMap), nil
case "ol":
return getDebianVersion(osReleaseMap), nil
case "amzn":
return getDebianVersion(osReleaseMap), nil
case "sles":
return getDebianVersion(osReleaseMap), nil
default:
return "", fmt.Errorf("Unsupported ID in /etc/os-release: %q", osReleaseMap["ID"])
}

View File

@@ -57,6 +57,24 @@ func TestGetOSVersionLinux(t *testing.T) {
expectedOSVersion: "rhel 7.7 (Maipo)",
expectErr: false,
},
{
name: "ol",
fakeOSReleasePath: "testdata/os-release-ol",
expectedOSVersion: "ol 9.0",
expectErr: false,
},
{
name: "amzn",
fakeOSReleasePath: "testdata/os-release-amzn",
expectedOSVersion: "amzn 2",
expectErr: false,
},
{
name: "sles",
fakeOSReleasePath: "testdata/os-release-sles",
expectedOSVersion: "sles 15-SP4",
expectErr: false,
},
{
name: "Unknown",
fakeOSReleasePath: "testdata/os-release-unknown",

9
pkg/util/testdata/os-release-amzn vendored Normal file
View File

@@ -0,0 +1,9 @@
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

18
pkg/util/testdata/os-release-ol vendored Normal file
View File

@@ -0,0 +1,18 @@
NAME="Oracle Linux Server"
VERSION="9.0"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.0"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.0"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:0:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.0
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.0

9
pkg/util/testdata/os-release-sles vendored Normal file
View File

@@ -0,0 +1,9 @@
NAME="SLES"
VERSION="15-SP4"
VERSION_ID="15.4"
PRETTY_NAME="SUSE Linux Enterprise Server 15 SP4"
ID="sles"
ID_LIKE="suse"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:15:sp4"
DOCUMENTATION_URL="https://documentation.suse.com/"