fix(promote): 基线解析适配真实两层结构(修复 walk 叶子误当 dict + 打印解包)

This commit is contained in:
ximenchuifeng committed 2026-08-22 13:45:42 +08:00
1 parent 3849548087
commit e2375a49d2
1 file changed
+6 -4
+6 -4
View File
@@ -85,10 +85,12 @@ lines = []
def walk(prefix, node):
for k, v in node.items():
key = f"{prefix}.{k}" if prefix else k
if isinstance(v, dict):
walk(key, v)
if not isinstance(v, dict):
continue
if "repository" in v and "tag" in v:
lines.append((key, v["repository"], v["tag"]))
else:
lines.append((key, v.get("repository", ""), v.get("tag", "")))
walk(key, v)
walk("", images)
out, skipped = [], []
for key, repo, tag in lines:
@@ -98,7 +100,7 @@ for key, repo, tag in lines:
sys.exit(f"[promote] 错误: demo image-version 中 {key} 缺 repository/tag")
out.append(f"{repo} {tag}")
open(dst, "w", encoding="utf-8").write("\n".join(out) + "\n")
print(f"[promote] 交付基线 {len(out)} 个镜像: " + ", ".join(r for r, _ in out))
print(f"[promote] 交付基线 {len(out)} 个镜像: " + ", ".join(l.split()[0] for l in out))
if skipped: print(f"[promote] 跳过 protocol 镜像: {', '.join(skipped)}")
PY