generate-release-meta: Factor out build-to-stream function
This avoids an indent; pass in the JSON data rather than having
it under a `with` statement.
Prep for further work.
@@ -68,10 +68,9 @@ if os.path.exists(args.output):
out = json.load(w)
print(f"Using existing release file {args.output}")
-for f in archbuilds:
- with open(f, 'r') as w:
- input_ = json.load(w)
+# Append the coreos-assembler build json `input_` to `out`, the target release stream.
+def append_build(out, input_):
arch = input_.get("coreos-assembler.basearch")
ensure_dup(input_, out, "buildid", "release")
@@ -175,6 +174,11 @@ for f in archbuilds:
else:
raise Exception("differing content detected for media type '{}'".format(media_type))
+
+for path in archbuilds:
+ with open(path) as f:
+ append_build(out, json.load(f))
+
with open(args.output, 'w') as w:
json.dump(out, w)
print(f"Successfully wrote release file at {args.output}")
