From e63fa485044ccd3b962f4f254256a15c21bfd488 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Sun, 7 Nov 2021 23:00:37 +0000 Subject: [PATCH] formats/v2: fix describe for mount without source Commit 5b1cd2b made `source` and `target` for mounts optional, but the corresponding code in `describe` still assumes that the device will always be present. Fix this so that source will only be used if it is set. --- osbuild/formats/v2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/osbuild/formats/v2.py b/osbuild/formats/v2.py index 94da3a7f..c3b32af0 100644 --- a/osbuild/formats/v2.py +++ b/osbuild/formats/v2.py @@ -77,10 +77,12 @@ def describe(manifest: Manifest, *, with_id=False) -> Dict: desc = { "name": mnt.name, "type": mnt.info.name, - "source": mnt.device.name, "target": mnt.target } + if mnt.device: + desc["source"] = mnt.device.name + if mnt.options: desc["options"] = mnt.options return desc