Skip to content

Commit

Permalink
fix: make properly recordable
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Laprun <[email protected]>
  • Loading branch information
metacosm committed Nov 7, 2024
1 parent dbce5ad commit bdf846e
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Map<String, CRDInfo>> infos;

Expand All @@ -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<String, Map<String, CRDInfo>> infos) {
this.infos = infos;
}

@IgnoreProperty
public Map<String, CRDInfo> getOrCreateCRDSpecVersionToInfoMapping(String crdName) {
return infos.computeIfAbsent(crdName, k -> new HashMap<>());
}

@IgnoreProperty
public Map<String, CRDInfo> getCRDNameToInfoMappings() {
return infos
.values().stream()
Expand All @@ -37,4 +43,10 @@ public Map<String, CRDInfo> 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<String, Map<String, CRDInfo>> getInfos() {
return infos;
}
}

0 comments on commit bdf846e

Please sign in to comment.