From d8e3aadb1b48e6dc3761097d265fc8a905a17747 Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Tue, 10 Dec 2024 16:57:12 +0530 Subject: [PATCH] chore: handle renamed drm extensions Handle renamed drm extensions. Fixes: https://github.com/siderolabs/talos/issues/9728 Signed-off-by: Noel Georgi --- internal/backend/extensions/extensions.go | 21 +++++++++++++++++-- .../backend/extensions/extensions_test.go | 14 +++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/internal/backend/extensions/extensions.go b/internal/backend/extensions/extensions.go index d46e6a57..b9bfd0a6 100644 --- a/internal/backend/extensions/extensions.go +++ b/internal/backend/extensions/extensions.go @@ -18,6 +18,7 @@ const OfficialPrefix = "siderolabs/" var ( talosV170 = semver.MustParse("1.7.0") talosV180 = semver.MustParse("1.8.0") + talosV190 = semver.MustParse("1.9.0") talosV17RenamedExtensions = newBiMap[string, string](map[string]string{ OfficialPrefix + "xe-guest-utilities": OfficialPrefix + "xen-guest-agent", @@ -29,6 +30,11 @@ var ( OfficialPrefix + "nonfree-kmod-nvidia": OfficialPrefix + "nonfree-kmod-nvidia-lts", OfficialPrefix + "nvidia-fabricmanager": OfficialPrefix + "nvidia-fabric-manager-lts", }) + + talosV19RenamedExtensions = newBiMap[string, string](map[string]string{ + OfficialPrefix + "i915-ucode": OfficialPrefix + "i915", + OfficialPrefix + "amdgpu-firmware": OfficialPrefix + "amdgpu", + }) ) // MapNames maps the extension names to their correct final names, taking extensions with the wrong name in their manifests into account. @@ -60,14 +66,15 @@ func MapNamesByVersion(extensions []string, talosVersion semver.Version) []strin gte170 := talosVersion.GTE(talosV170) gte180 := talosVersion.GTE(talosV180) + gte190 := talosVersion.GTE(talosV190) return xslices.Map(extensions, func(extension string) string { - return mapSingleNameByVersion(extension, gte170, gte180) + return mapSingleNameByVersion(extension, gte170, gte180, gte190) }) } // mapSingleNameByVersion returns the renamed extension based on the talos version. -func mapSingleNameByVersion(extension string, gte170, gte180 bool) string { +func mapSingleNameByVersion(extension string, gte170, gte180, get190 bool) string { if gte170 { if name, ok := talosV17RenamedExtensions.Get(extension); ok { return name @@ -88,6 +95,16 @@ func mapSingleNameByVersion(extension string, gte170, gte180 bool) string { } } + if get190 { + if name, ok := talosV19RenamedExtensions.Get(extension); ok { + return name + } + } else { + if name, ok := talosV19RenamedExtensions.GetInverse(extension); ok { + return name + } + } + return extension } diff --git a/internal/backend/extensions/extensions_test.go b/internal/backend/extensions/extensions_test.go index 55140af6..9e441624 100644 --- a/internal/backend/extensions/extensions_test.go +++ b/internal/backend/extensions/extensions_test.go @@ -72,4 +72,18 @@ func TestMap(t *testing.T) { "siderolabs/xen-guest-agent", // kept as-is because not in the renamed list }, mapped) }) + + t.Run("talos-v1.9", func(t *testing.T) { + exts := []string{ + "siderolabs/i915-ucode", + "siderolabs/amdgpu-firmware", + } + + mapped := extensions.MapNamesByVersion(exts, semver.MustParse("1.9.0")) + + require.Equal(t, []string{ + "siderolabs/i915", // mapped to the new name + "siderolabs/amdgpu", // mapped to the new name + }, mapped) + }) }