bundles/simple-icinga-dashboard: config is a toml file now
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit

This commit is contained in:
Franzi 2021-04-10 16:08:52 +02:00
parent b33ddaadb5
commit 36bd6f5755
Signed by: kunsi
GPG key ID: 12E3D2136B818350
5 changed files with 39 additions and 26 deletions

19
libs/toml.py Normal file
View file

@ -0,0 +1,19 @@
from tomlkit import document as toml_document
from bundlewrap.utils import Fault
# Copied from bw core, because bw core doesn't support faults
def dict_to_toml(dict_obj):
toml_doc = toml_document()
for key, value in sorted(dict_obj.items()):
if isinstance(value, tuple):
toml_doc[key] = list(value)
elif isinstance(value, set):
toml_doc[key] = sorted(value)
elif isinstance(value, dict):
toml_doc[key] = dict_to_toml(value)
elif isinstance(value, Fault):
toml_doc[key] = str(value)
else:
toml_doc[key] = value
return toml_doc