From 0afa7cc6ff54cb3daa9cc40e9ac06355cb6e2c6a Mon Sep 17 00:00:00 2001 From: Alexandru Matei Date: Thu, 27 Oct 2022 14:54:42 +0300 Subject: [PATCH] Add support for SLES, Oracle and Amazon Linux --- pkg/util/helpers_linux.go | 6 ++++++ pkg/util/helpers_linux_test.go | 18 ++++++++++++++++++ pkg/util/testdata/os-release-amzn | 9 +++++++++ pkg/util/testdata/os-release-ol | 18 ++++++++++++++++++ pkg/util/testdata/os-release-sles | 9 +++++++++ 5 files changed, 60 insertions(+) create mode 100644 pkg/util/testdata/os-release-amzn create mode 100644 pkg/util/testdata/os-release-ol create mode 100644 pkg/util/testdata/os-release-sles diff --git a/pkg/util/helpers_linux.go b/pkg/util/helpers_linux.go index c4e22406d..1fb5fc16d 100644 --- a/pkg/util/helpers_linux.go +++ b/pkg/util/helpers_linux.go @@ -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"]) } diff --git a/pkg/util/helpers_linux_test.go b/pkg/util/helpers_linux_test.go index 1f5944def..ebd6c001b 100644 --- a/pkg/util/helpers_linux_test.go +++ b/pkg/util/helpers_linux_test.go @@ -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", diff --git a/pkg/util/testdata/os-release-amzn b/pkg/util/testdata/os-release-amzn new file mode 100644 index 000000000..2903a695f --- /dev/null +++ b/pkg/util/testdata/os-release-amzn @@ -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/" \ No newline at end of file diff --git a/pkg/util/testdata/os-release-ol b/pkg/util/testdata/os-release-ol new file mode 100644 index 000000000..84a568334 --- /dev/null +++ b/pkg/util/testdata/os-release-ol @@ -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 \ No newline at end of file diff --git a/pkg/util/testdata/os-release-sles b/pkg/util/testdata/os-release-sles new file mode 100644 index 000000000..d50a988ef --- /dev/null +++ b/pkg/util/testdata/os-release-sles @@ -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/" \ No newline at end of file