diff --git a/stateless_uptime_kuma/tree_gen.py b/stateless_uptime_kuma/tree_gen.py index e0e573a..4897167 100644 --- a/stateless_uptime_kuma/tree_gen.py +++ b/stateless_uptime_kuma/tree_gen.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) def die_tag_format_error(): logger.error( - "Fatal: You must provide tags in monitors in the format [[name, value]]" + "Fatal: You must provide tags in monitors in the format [{name:str, value:str}] (value is optional)" ) sys.exit(1) @@ -27,10 +27,10 @@ def from_dict(api, tree): for m in monitors: associated_tags = [] for tag in m.get("tags", []): - if not isinstance(tag, list): + if not isinstance(tag, dict) or "name" not in tag: die_tag_format_error() try: - associated_tags.append((indexed_tags[tag[0]], tag[1])) + associated_tags.append((indexed_tags[tag["name"]], tag.get("value"))) except IndexError: die_tag_format_error() m["tags"] = associated_tags diff --git a/tests/02_tags.json b/tests/02_tags.json index c0616ae..1b57ef9 100644 --- a/tests/02_tags.json +++ b/tests/02_tags.json @@ -11,7 +11,7 @@ "name":"test" }], "monitors": [{ - "tags": [["test", "value"]], + "tags": [{ "name":"test", "value":"value"}], "notifications": [ "dgn" ], "old_name": "test_monitor", "name": "test_monitor2",