diff mbox series

[yocto-autobuilder-helper,04/11] scripts/utils: add getconfigdict() for dict-type config values

Message ID d85e765060f18251c2072ad3d1cb12219a2b0085.1778202125.git.tim.orling@konsulko.com
State New
Headers show
Series [yocto-autobuilder-helper,01/11] scripts/utils: fix stale extraction dir when tarball is updated | expand

Commit Message

Tim Orling May 8, 2026, 2 a.m. UTC
From: Tim Orling <tim.orling@konsulko.com>

Parallel to getconfiglist(), but for JSON object values. The merge
priority is defaults < target-level < step-level so that more-specific
keys win: a step can override individual entries in a target-level dict
without replacing the whole thing, and both levels refine the defaults.

Used by the upcoming CONTAINER_IMAGES support, where each entry maps a
Yocto recipe name (the on-disk OCI path stem) to an image name (the
name pushed to the container registry).

AI-Generated: Claude Cowork Sonnet 4.6
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
 scripts/utils.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/scripts/utils.py b/scripts/utils.py
index ea905d9..112ebc2 100644
--- a/scripts/utils.py
+++ b/scripts/utils.py
@@ -112,6 +112,21 @@  def getconfiglist(name, config, target, stepnum):
         ret.extend(config['defaults'][name])
     return expandresult(ret, config)
 
+# Get a build configuration dict, merging defaults < target < step so that
+# more-specific entries win (step-level keys override target-level, which
+# override defaults).
+def getconfigdict(name, config, target, stepnum):
+    ret = {}
+    step = "step" + str(stepnum)
+    if name in config['defaults']:
+        ret.update(config['defaults'][name])
+    if target in config['overrides']:
+        if name in config['overrides'][target]:
+            ret.update(config['overrides'][target][name])
+        if step in config['overrides'][target] and name in config['overrides'][target][step]:
+            ret.update(config['overrides'][target][step][name])
+    return expandresult(ret, config)
+
 # Return only unique configuration values (identified with '=' in them)
 def getconfiglistfilter(name, config, target, stepnum):
     def merge(main, newvals):