fix(promote): 基线解析适配真实两层结构(修复 walk 叶子误当 dict + 打印解包)
This commit is contained in:
1 parent
3849548087
commit
e2375a49d2
1 file changed
+6
-4
+6
-4
@@ -85,10 +85,12 @@ lines = []
|
|||||||
def walk(prefix, node):
|
def walk(prefix, node):
|
||||||
for k, v in node.items():
|
for k, v in node.items():
|
||||||
key = f"{prefix}.{k}" if prefix else k
|
key = f"{prefix}.{k}" if prefix else k
|
||||||
if isinstance(v, dict):
|
if not isinstance(v, dict):
|
||||||
walk(key, v)
|
continue
|
||||||
|
if "repository" in v and "tag" in v:
|
||||||
|
lines.append((key, v["repository"], v["tag"]))
|
||||||
else:
|
else:
|
||||||
lines.append((key, v.get("repository", ""), v.get("tag", "")))
|
walk(key, v)
|
||||||
walk("", images)
|
walk("", images)
|
||||||
out, skipped = [], []
|
out, skipped = [], []
|
||||||
for key, repo, tag in lines:
|
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")
|
sys.exit(f"[promote] 错误: demo image-version 中 {key} 缺 repository/tag")
|
||||||
out.append(f"{repo} {tag}")
|
out.append(f"{repo} {tag}")
|
||||||
open(dst, "w", encoding="utf-8").write("\n".join(out) + "\n")
|
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)}")
|
if skipped: print(f"[promote] 跳过 protocol 镜像: {', '.join(skipped)}")
|
||||||
PY
|
PY
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user