kubeListsToAttrs: skip CustomResourceDefinition objects

This commit is contained in:
lillecarl 2026-01-21 17:28:08 +00:00
commit eb2a380f7b
4 changed files with 13 additions and 3 deletions

View file

@ -107,7 +107,7 @@ in
config = {
# list to attrset convertion is just a preconfigured override
overrides = lib.optional releaseConfig.convertLists (
lib.mkBefore (object: (lib.walkWithPath lib.kubeListsToAttrs) object)
lib.mkBefore (object: (lib.walkWithPath (lib.kubeListsToAttrs object)) object)
);
objects =

View file

@ -44,7 +44,7 @@ let
config = {
# list to attrset convertion is just a preconfigured override
overrides = lib.optional yamlConfig.convertLists (
lib.mkBefore (object: (lib.walkWithPath lib.kubeListsToAttrs) object)
lib.mkBefore (object: (lib.walkWithPath (lib.kubeListsToAttrs object)) object)
);
objects =

View file

@ -87,8 +87,18 @@ self: lib: {
# Master transformer: Converts all standard JSON lists into special attribute sets
# to make them easily overridable in Nix.
# Takes the root object first to allow skipping entire objects (e.g., CRDs).
kubeListsToAttrs =
object:
let
# Never transform CustomResourceDefinition objects. Their spec contains OpenAPI schemas
# with deeply nested structures that must not be converted to named/numbered lists.
isCRD = lib.isAttrs object && (object.kind or null) == "CustomResourceDefinition";
in
path: value:
if isCRD then
value
else
let
currentKey = lib.last (path ++ [ null ]);
# Heuristic to identify a list that should become a `_namedlist`.

View file

@ -23,5 +23,5 @@ in
rec {
ainputVersion = input;
blistVersion = (lib.walkWithPath lib.kubeAttrsToLists) ainputVersion;
cattrVersion = (lib.walkWithPath lib.kubeListsToAttrs) blistVersion;
cattrVersion = (lib.walkWithPath (lib.kubeListsToAttrs blistVersion)) blistVersion;
}