formats: move pipeline description here

The description of a pipeline is format dependent and thus needs
to be located at the specific format module.
Temporarily remove two tests; they should be added back to a format
specific test suit.
This commit is contained in:
Christian Kellner 2020-12-16 18:18:19 +01:00 committed by Tom Gundersen
parent a13783f67b
commit 4ab52c3764
4 changed files with 33 additions and 59 deletions

View file

@ -5,6 +5,35 @@ from osbuild.meta import Index, ValidationResult
from ..pipeline import Pipeline, detect_host_runner
def describe(pipeline: Pipeline, *, with_id=False) -> Dict:
"""Create the manifest description for the pipeline"""
def describe_stage(stage):
description = {"name": stage.name}
if stage.options:
description["options"] = stage.options
if with_id:
description["id"] = stage.id
return description
description = {}
if pipeline.build:
build = pipeline.build
description["build"] = {
"pipeline": describe(build, with_id=with_id),
"runner": pipeline.runner
}
if pipeline.stages:
stages = [describe_stage(s) for s in pipeline.stages]
description["stages"] = stages
if pipeline.assembler:
assembler = describe_stage(pipeline.assembler)
description["assembler"] = assembler
return description
def load_build(description: Dict, sources_options: Dict):
pipeline = description.get("pipeline")
if pipeline: