osbuild.py/pipeline: assign a unique id to every pipeline
This uniquely identifies a pipeline based on its content. Pipelines are considered equal modulo whitespace and the order of object elements. The intention is that two runs of a pipeline with the same id generates functionaly equivalent ids. It is up to the writers of stages and pipelines to ensure this property holds. Signed-off-by: Tom Gundersen <teg@jklm.no>
This commit is contained in:
parent
1219f1dc55
commit
f25cffa151
2 changed files with 8 additions and 0 deletions
3
osbuild
3
osbuild
|
|
@ -30,6 +30,9 @@ if __name__ == "__main__":
|
|||
pipeline = json.load(f)
|
||||
pipeline = osbuild.Pipeline(pipeline)
|
||||
|
||||
print()
|
||||
print(f"{RESET}{BOLD}Pipeline: {pipeline.id}{RESET}")
|
||||
|
||||
try:
|
||||
pipeline.run(args.input_dir, args.output_dir, interactive=True)
|
||||
except KeyboardInterrupt:
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
|
@ -203,6 +204,10 @@ def print_header(title, options, machine_name):
|
|||
|
||||
class Pipeline:
|
||||
def __init__(self, pipeline):
|
||||
m = hashlib.sha256()
|
||||
m.update(json.dumps(pipeline, sort_keys=True).encode())
|
||||
|
||||
self.id = m.hexdigest()
|
||||
self.stages = pipeline["stages"]
|
||||
self.assembler = pipeline.get("assembler")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue