Merge pull request 'Inventory: init inventory.tags for globally defined static and dynamic tags' (#2328) from hsjobeki/clan-core:hsjobeki-main into main
This commit is contained in:
@@ -36,3 +36,4 @@ class Inventory:
|
||||
meta: Meta
|
||||
machines: dict[str, Machine] = field(default_factory = dict)
|
||||
services: dict[str, Service] = field(default_factory = dict)
|
||||
tags: dict[str, list[str]] = field(default_factory = dict)
|
||||
|
||||
@@ -88,6 +88,7 @@
|
||||
buildInputs = [
|
||||
pkgs.python3
|
||||
pkgs.json2ts
|
||||
pkgs.jq
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
@@ -98,7 +99,9 @@
|
||||
json2ts --input $out/API.json > $out/API.ts
|
||||
|
||||
# Retrieve python API Typescript types
|
||||
json2ts --input ${self'.legacyPackages.schemas.inventory}/schema.json > $out/Inventory.ts
|
||||
# delete the reserved tags from typechecking because the conversion library doesn't support them
|
||||
jq 'del(.properties.tags.properties)' ${self'.legacyPackages.schemas.inventory}/schema.json > schema.json
|
||||
json2ts --input schema.json > $out/Inventory.ts
|
||||
cp ${self'.legacyPackages.schemas.inventory}/* $out
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -24,7 +24,10 @@ def map_json_type(
|
||||
res |= map_json_type(t)
|
||||
return res
|
||||
if isinstance(json_type, dict):
|
||||
return map_json_type(json_type.get("type"))
|
||||
items = json_type.get("items")
|
||||
if items:
|
||||
nested_types = map_json_type(items)
|
||||
return map_json_type(json_type.get("type"), nested_types)
|
||||
if json_type == "string":
|
||||
return {"str"}
|
||||
if json_type == "integer":
|
||||
|
||||
Reference in New Issue
Block a user