]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: utils: modeling: rename _PREVIOUS_SCHEMA to _LAYER
authorAleš Mrázek <ales.mrazek@nic.cz>
Mon, 11 Jul 2022 09:04:09 +0000 (11:04 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Mon, 11 Jul 2022 09:04:09 +0000 (11:04 +0200)
manager/knot_resolver_manager/datamodel/config_schema.py
manager/knot_resolver_manager/datamodel/network_schema.py
manager/knot_resolver_manager/datamodel/options_schema.py
manager/knot_resolver_manager/utils/modeling/schema_node.py
manager/tests/unit/utils/test_modeling.py

index dfcf82814f9976ba36adba16c5f28683dcd531f5..54462884cfecb68f81cdc9e374263a6ad1dfcc3d 100644 (file)
@@ -124,7 +124,7 @@ class KresConfig(SchemaNode):
         monitoring: MonitoringSchema = MonitoringSchema()
         lua: LuaSchema = LuaSchema()
 
-    _PREVIOUS_SCHEMA = Raw
+    _LAYER = Raw
 
     nsid: Optional[str]
     hostname: str
index d4f296d5d2cbbb5c631dd55ea4d87a48239eb563..e0760dcf55e97ace1c576d56e694f6d283a35553 100644 (file)
@@ -89,7 +89,7 @@ class ListenSchema(SchemaNode):
         kind: KindEnum = "dns"
         freebind: bool = False
 
-    _PREVIOUS_SCHEMA = Raw
+    _LAYER = Raw
 
     interface: Union[None, InterfaceOptionalPort, List[InterfaceOptionalPort]]
     unix_socket: Union[None, CheckedPath, List[CheckedPath]]
index 6d23248e580e8273fdc77c159f4b74bc7a15b794..a407c27ce087a32101f1d804dbecfaa828f2f851 100644 (file)
@@ -54,7 +54,7 @@ class OptionsSchema(SchemaNode):
         serve_stale: bool = False
         prediction: Union[bool, PredictionSchema] = False
 
-    _PREVIOUS_SCHEMA = Raw
+    _LAYER = Raw
 
     glue_checking: GlueCheckingEnum
     qname_minimisation: bool
index f670ee6f7640d602a9ca858e663ed642b431ad93..0ee00d278266137241cdaa5b2b10f6fff591bd20 100644 (file)
@@ -438,7 +438,7 @@ class SchemaNode(Serializable):
     during validation, raise a `ValueError` exception.
 
     Using this, you can convert any input values into any type and field you want. To make the conversion easier
-    to write, you could also specify a special class variable called `_PREVIOUS_SCHEMA` pointing to another
+    to write, you could also specify a special class variable called `_LAYER` pointing to another
     SchemaNode class. This causes the source object to be first parsed as the specified SchemaNode and after that
     used a source for this class. This therefore allows nesting of transformation functions.
 
@@ -465,7 +465,7 @@ class SchemaNode(Serializable):
     See tests/utils/test_modelling.py for example usage.
     """
 
-    _PREVIOUS_SCHEMA: Optional[Type["SchemaNode"]] = None
+    _LAYER: Optional[Type["SchemaNode"]] = None
 
     def _assign_default(self, name: str, python_type: Any, object_path: str) -> None:
         cls = self.__class__
@@ -543,8 +543,8 @@ class SchemaNode(Serializable):
         self._source: Union[ParsedTree, SchemaNode] = source
 
         # construct lower level schema node first if configured to do so
-        if self._PREVIOUS_SCHEMA is not None:
-            source = self._PREVIOUS_SCHEMA(source, object_path=object_path)  # pylint: disable=not-callable
+        if self._LAYER is not None:
+            source = self._LAYER(source, object_path=object_path)  # pylint: disable=not-callable
 
         # assign fields
         used_keys = self._assign_fields(source, object_path)
@@ -620,8 +620,8 @@ class SchemaNode(Serializable):
 
     @classmethod
     def json_schema(cls: Type["SchemaNode"], include_schema_definition: bool = True) -> Dict[Any, Any]:
-        if cls._PREVIOUS_SCHEMA is not None:
-            return cls._PREVIOUS_SCHEMA.json_schema(include_schema_definition=include_schema_definition)
+        if cls._LAYER is not None:
+            return cls._LAYER.json_schema(include_schema_definition=include_schema_definition)
 
         schema: Dict[Any, Any] = {}
         if include_schema_definition:
index f7190b8e6479a46e7d3a57fda50543e436b43395..b8dfcae7b55da2ffd677caafefb862d7c0b0fbe5 100644 (file)
@@ -128,7 +128,7 @@ def test_partial_mutations():
         inner: InnerSchema = InnerSchema()
 
     class ConfSchema(SchemaNode):
-        _PREVIOUS_SCHEMA = ConfPreviousSchema
+        _LAYER = ConfPreviousSchema
 
         workers: int
         lua_config: Optional[str]