From fda3234b6440b12b009b0b0f213e585abd30787e Mon Sep 17 00:00:00 2001 From: Henry Beberman Date: Thu, 28 Mar 2024 18:34:00 +0000 Subject: [PATCH] Add support for CBL-Mariner and Azure Linux --- pkg/util/helpers_linux.go | 4 ++++ pkg/util/helpers_linux_test.go | 12 ++++++++++++ pkg/util/testdata/os-release-azurelinux | 9 +++++++++ pkg/util/testdata/os-release-mariner | 9 +++++++++ 4 files changed, 34 insertions(+) create mode 100644 pkg/util/testdata/os-release-azurelinux create mode 100644 pkg/util/testdata/os-release-mariner diff --git a/pkg/util/helpers_linux.go b/pkg/util/helpers_linux.go index b279fbec5..736a973f1 100644 --- a/pkg/util/helpers_linux.go +++ b/pkg/util/helpers_linux.go @@ -64,6 +64,10 @@ func getOSVersion(osReleasePath string) (string, error) { return getDebianVersion(osReleaseMap), nil case "sles": return getDebianVersion(osReleaseMap), nil + case "mariner": + return getDebianVersion(osReleaseMap), nil + case "azurelinux": + 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 ebd6c001b..ca28637ce 100644 --- a/pkg/util/helpers_linux_test.go +++ b/pkg/util/helpers_linux_test.go @@ -75,6 +75,18 @@ func TestGetOSVersionLinux(t *testing.T) { expectedOSVersion: "sles 15-SP4", expectErr: false, }, + { + name: "mariner", + fakeOSReleasePath: "testdata/os-release-mariner", + expectedOSVersion: "mariner 2.0.20240123", + expectErr: false, + }, + { + name: "azurelinux", + fakeOSReleasePath: "testdata/os-release-azurelinux", + expectedOSVersion: "azurelinux 3.0.20240328", + expectErr: false, + }, { name: "Unknown", fakeOSReleasePath: "testdata/os-release-unknown", diff --git a/pkg/util/testdata/os-release-azurelinux b/pkg/util/testdata/os-release-azurelinux new file mode 100644 index 000000000..3cd911735 --- /dev/null +++ b/pkg/util/testdata/os-release-azurelinux @@ -0,0 +1,9 @@ +NAME="Microsoft Azure Linux" +VERSION="3.0.20240328" +ID=azurelinux +VERSION_ID="3.0" +PRETTY_NAME="Microsoft Azure Linux 3.0" +ANSI_COLOR="1;34" +HOME_URL="https://aka.ms/azurelinux" +BUG_REPORT_URL="https://aka.ms/azurelinux" +SUPPORT_URL="https://aka.ms/azurelinux" \ No newline at end of file diff --git a/pkg/util/testdata/os-release-mariner b/pkg/util/testdata/os-release-mariner new file mode 100644 index 000000000..c004191c1 --- /dev/null +++ b/pkg/util/testdata/os-release-mariner @@ -0,0 +1,9 @@ +NAME="Common Base Linux Mariner" +VERSION="2.0.20240123" +ID=mariner +VERSION_ID="2.0" +PRETTY_NAME="CBL-Mariner/Linux" +ANSI_COLOR="1;34" +HOME_URL="https://aka.ms/cbl-mariner" +BUG_REPORT_URL="https://aka.ms/cbl-mariner" +SUPPORT_URL="https://aka.ms/cbl-mariner" \ No newline at end of file