From cadd475940dd3b657a5fa60ffee981edb22ada66 Mon Sep 17 00:00:00 2001 From: Johanan Liebermann Date: Mon, 11 Aug 2025 19:03:38 +0300 Subject: [PATCH] Add support for Flatcar Container Linux Signed-off-by: Johanan Liebermann --- pkg/util/helpers_linux.go | 2 ++ pkg/util/helpers_linux_test.go | 6 ++++++ pkg/util/testdata/os-release-flatcar | 13 +++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 pkg/util/testdata/os-release-flatcar diff --git a/pkg/util/helpers_linux.go b/pkg/util/helpers_linux.go index 425e1fa8b..6bd10b319 100644 --- a/pkg/util/helpers_linux.go +++ b/pkg/util/helpers_linux.go @@ -70,6 +70,8 @@ func getOSVersion(osReleasePath string) (string, error) { return getDebianVersion(osReleaseMap), nil case "azurelinux": return getDebianVersion(osReleaseMap), nil + case "flatcar": + 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 7eda0d961..78bd4660f 100644 --- a/pkg/util/helpers_linux_test.go +++ b/pkg/util/helpers_linux_test.go @@ -93,6 +93,12 @@ func TestGetOSVersionLinux(t *testing.T) { expectedOSVersion: "azurelinux 3.0.20240328", expectErr: false, }, + { + name: "flatcar", + fakeOSReleasePath: "testdata/os-release-flatcar", + expectedOSVersion: "flatcar 4372.0.1", + expectErr: false, + }, { name: "Unknown", fakeOSReleasePath: "testdata/os-release-unknown", diff --git a/pkg/util/testdata/os-release-flatcar b/pkg/util/testdata/os-release-flatcar new file mode 100644 index 000000000..92c582aec --- /dev/null +++ b/pkg/util/testdata/os-release-flatcar @@ -0,0 +1,13 @@ +NAME="Flatcar Container Linux by Kinvolk" +ID=flatcar +ID_LIKE=coreos +VERSION=4372.0.1 +VERSION_ID=4372.0.1 +BUILD_ID=2025-07-06-2244 +SYSEXT_LEVEL=1.0 +PRETTY_NAME="Flatcar Container Linux by Kinvolk 4372.0.1 (Oklo)" +ANSI_COLOR="38;5;75" +HOME_URL="https://flatcar.org/" +BUG_REPORT_URL="https://issues.flatcar.org" +FLATCAR_BOARD="amd64-usr" +CPE_NAME="cpe:2.3:o:flatcar-linux:flatcar_linux:4372.0.1:*:*:*:*:*:*:*"