test: metadata in describe
Michael Vogt pointed out that testcases start failing when we describe the new format. Let's add a test case and fix the describe to include the metadata. Metadata is freeform in the `Manifest` instance but it is stored on it during loading (at which time its properties are validated) and returned as-is on describe. Signed-off-by: Simon de Vlieger <supakeen@redhat.com>
This commit is contained in:
parent
12dcf3c6d9
commit
8429acf7e3
3 changed files with 21 additions and 1 deletions
|
|
@ -166,6 +166,9 @@ def describe(manifest: Manifest, *, with_id=False) -> Dict:
|
|||
"pipelines": pipelines
|
||||
}
|
||||
|
||||
if manifest.metadata:
|
||||
description["metadata"] = manifest.metadata
|
||||
|
||||
if sources:
|
||||
description["sources"] = sources
|
||||
|
||||
|
|
@ -355,10 +358,15 @@ def load(description: Dict, index: Index) -> Manifest:
|
|||
|
||||
sources = description.get("sources", {})
|
||||
pipelines = description.get("pipelines", [])
|
||||
metadata = description.get("metadata", {})
|
||||
|
||||
manifest = Manifest()
|
||||
source_refs = set()
|
||||
|
||||
# metadata
|
||||
for key, value in metadata.items():
|
||||
manifest.add_metadata(key, value)
|
||||
|
||||
# load the sources
|
||||
for name, desc in sources.items():
|
||||
info = index.get_module_info("Source", name)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import hashlib
|
|||
import json
|
||||
import os
|
||||
from fnmatch import fnmatch
|
||||
from typing import Dict, Generator, Iterable, Iterator, List, Optional
|
||||
from typing import Any, Dict, Generator, Iterable, Iterator, List, Optional
|
||||
|
||||
from . import buildroot, host, objectstore, remoteloop
|
||||
from .api import API
|
||||
|
|
@ -388,9 +388,13 @@ class Manifest:
|
|||
"""Representation of a pipeline and its sources"""
|
||||
|
||||
def __init__(self):
|
||||
self.metadata = {}
|
||||
self.pipelines = collections.OrderedDict()
|
||||
self.sources = []
|
||||
|
||||
def add_metadata(self, name: str, data: Dict[str, Any]) -> None:
|
||||
self.metadata[name] = data
|
||||
|
||||
def add_pipeline(
|
||||
self,
|
||||
name: str,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,14 @@ import osbuild.meta
|
|||
|
||||
BASIC_PIPELINE = {
|
||||
"version": "2",
|
||||
"metadata": {
|
||||
"generators": [
|
||||
{
|
||||
"name": "handcrafted",
|
||||
"version": "NaN",
|
||||
},
|
||||
],
|
||||
},
|
||||
"sources": {
|
||||
"org.osbuild.curl": {
|
||||
"items": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue