From eb2a380f7b3392fc9fa388cb95eb91d2ac21c5e7 Mon Sep 17 00:00:00 2001 From: lillecarl Date: Wed, 21 Jan 2026 17:28:08 +0000 Subject: [PATCH] kubeListsToAttrs: skip CustomResourceDefinition objects --- helm.nix | 2 +- importyaml.nix | 2 +- lib/default.nix | 10 ++++++++++ tmp/_namedlist.nix | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/helm.nix b/helm.nix index 4b2c545..8dc9505 100644 --- a/helm.nix +++ b/helm.nix @@ -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 = diff --git a/importyaml.nix b/importyaml.nix index 0e3ceb2..218496a 100644 --- a/importyaml.nix +++ b/importyaml.nix @@ -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 = diff --git a/lib/default.nix b/lib/default.nix index f0d7332..6703bc7 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -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`. diff --git a/tmp/_namedlist.nix b/tmp/_namedlist.nix index 325bf08..ff5384d 100644 --- a/tmp/_namedlist.nix +++ b/tmp/_namedlist.nix @@ -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; }