formats: extract manifest loading into module
Extract the code that loads a pipeline from a pipeline description, i.e. a manifest, into a new module inside a new 'formats' package. The idea is to have different descriptions, i.e. different formats, for the same internal representation. This allows changing the internal representation, i.e. data structures, but still having the same external description. Later a new description might be added that better matches the new internal representation.
This commit is contained in:
parent
40a716d3ce
commit
aaf61ce9fc
4 changed files with 37 additions and 31 deletions
32
osbuild/formats/v1.py
Normal file
32
osbuild/formats/v1.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
# Version 1 of the manifest description
|
||||
|
||||
from ..pipeline import Pipeline, detect_host_runner
|
||||
|
||||
|
||||
def load_build(description, sources_options):
|
||||
pipeline = description.get("pipeline")
|
||||
if pipeline:
|
||||
build_pipeline = load(pipeline, sources_options)
|
||||
else:
|
||||
build_pipeline = None
|
||||
|
||||
return build_pipeline, description["runner"]
|
||||
|
||||
|
||||
def load(description, sources_options):
|
||||
build = description.get("build")
|
||||
if build:
|
||||
build_pipeline, runner = load_build(build, sources_options)
|
||||
else:
|
||||
build_pipeline, runner = None, detect_host_runner()
|
||||
|
||||
pipeline = Pipeline(runner, build_pipeline)
|
||||
|
||||
for s in description.get("stages", []):
|
||||
pipeline.add_stage(s["name"], sources_options, s.get("options", {}))
|
||||
|
||||
a = description.get("assembler")
|
||||
if a:
|
||||
pipeline.set_assembler(a["name"], a.get("options", {}))
|
||||
|
||||
return pipeline
|
||||
Loading…
Add table
Add a link
Reference in a new issue