From bdf846e6cbd84f8d803efb6b78398036005ef9e3 Mon Sep 17 00:00:00 2001 From: Chris Laprun Date: Tue, 5 Nov 2024 15:42:54 +0100 Subject: [PATCH] fix: make properly recordable Signed-off-by: Chris Laprun --- .../io/quarkiverse/operatorsdk/runtime/CRDInfos.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/CRDInfos.java b/core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/CRDInfos.java index d72253e00..226596e4d 100644 --- a/core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/CRDInfos.java +++ b/core/runtime/src/main/java/io/quarkiverse/operatorsdk/runtime/CRDInfos.java @@ -6,6 +6,9 @@ import java.util.function.Function; import java.util.stream.Collectors; +import io.quarkus.runtime.annotations.IgnoreProperty; +import io.quarkus.runtime.annotations.RecordableConstructor; + public class CRDInfos { private final Map> infos; @@ -17,14 +20,17 @@ public CRDInfos(CRDInfos other) { this(new ConcurrentHashMap<>(other.infos)); } + @RecordableConstructor // constructor needs to be recordable for the class to be passed around by Quarkus private CRDInfos(Map> infos) { this.infos = infos; } + @IgnoreProperty public Map getOrCreateCRDSpecVersionToInfoMapping(String crdName) { return infos.computeIfAbsent(crdName, k -> new HashMap<>()); } + @IgnoreProperty public Map getCRDNameToInfoMappings() { return infos .values().stream() @@ -37,4 +43,10 @@ public Map getCRDNameToInfoMappings() { public void addCRDInfoFor(String crdName, String crdSpecVersion, CRDInfo crdInfo) { getOrCreateCRDSpecVersionToInfoMapping(crdName).put(crdSpecVersion, crdInfo); } + + // Needed by Quarkus: if this method isn't present, state is not properly set + @SuppressWarnings("unused") + public Map> getInfos() { + return infos; + } }