]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: datamodel: all Union[List[T], T] removed
authorAleš Mrázek <ales.mrazek@nic.cz>
Wed, 19 Apr 2023 13:47:12 +0000 (15:47 +0200)
committerAleš Mrázek <ales.mrazek@nic.cz>
Fri, 9 Jun 2023 11:54:07 +0000 (11:54 +0000)
manager/etc/knot-resolver/config.dev.yml
manager/etc/knot-resolver/config.policy.dev.yml
manager/knot_resolver_manager/datamodel/forward_schema.py
manager/knot_resolver_manager/datamodel/network_schema.py
manager/knot_resolver_manager/datamodel/types/__init__.py
manager/knot_resolver_manager/datamodel/types/types.py

index 7555b98c734461d554c8656c7cf911da357cd99e..e9d63dc961527eddaf4421d227cb488a4aa338c1 100644 (file)
@@ -11,4 +11,4 @@ logging:
     - supervisord
 network:
   listen:
-    - interface: 127.0.0.1@5353
+    - interface: [127.0.0.1@5353]
index 5f5a7429d0214dfffee4ad215aaef59d152fb2ca..e0d2646d75514f194dbafc44d1dfc498c71010c8 100644 (file)
@@ -11,7 +11,7 @@ logging:
     - supervisord
 network:
   listen:
-    - interface: 127.0.0.1@5353
+    - interface: [127.0.0.1@5353]
 
 views:
   - subnets: [127.0.0.0/24]
index b14cc6e20b9bac058f843e11d26c39a3f4081a67..7c1227cf896a089ba3175f61c4fc7f69231638f2 100644 (file)
@@ -19,9 +19,9 @@ class ForwardServerSchema(ConfigSchema):
     ca_file: Path to CA certificate file.
     """
 
-    address: Union[IPAddressOptionalPort, List[IPAddressOptionalPort]]
+    address: List[IPAddressOptionalPort]
     transport: Optional[Literal["tls"]] = None
-    pin_sha256: Optional[Union[str, List[str]]] = None
+    pin_sha256: Optional[List[str]] = None
     hostname: Optional[DomainName] = None
     ca_file: Optional[FilePath] = None
 
index 0a177e395f51c888ee57a9de26f1d199bfc0575e..a12ebe637a9ae57426cc6c5ae4d4367a70581fa8 100644 (file)
@@ -84,21 +84,21 @@ class ListenSchema(ConfigSchema):
         freebind: Used for binding to non-local address.
         """
 
-        interface: Union[None, InterfaceOptionalPort, List[InterfaceOptionalPort]] = None
-        unix_socket: Union[None, FilePath, List[FilePath]] = None
+        interface: Optional[List[InterfaceOptionalPort]] = None
+        unix_socket: Optional[List[FilePath]] = None
         port: Optional[PortNumber] = None
         kind: KindEnum = "dns"
         freebind: bool = False
 
     _LAYER = Raw
 
-    interface: Union[None, InterfaceOptionalPort, List[InterfaceOptionalPort]]
-    unix_socket: Union[None, FilePath, List[FilePath]]
+    interface: Optional[List[InterfaceOptionalPort]]
+    unix_socket: Optional[List[FilePath]]
     port: Optional[PortNumber]
     kind: KindEnum
     freebind: bool
 
-    def _interface(self, origin: Raw) -> Union[None, InterfaceOptionalPort, List[InterfaceOptionalPort]]:
+    def _interface(self, origin: Raw) -> Optional[List[InterfaceOptionalPort]]:
         if isinstance(origin.interface, list):
             port_set: Optional[bool] = None
             for intrfc in origin.interface:
@@ -175,6 +175,6 @@ class NetworkSchema(ConfigSchema):
     tls: TLSSchema = TLSSchema()
     proxy_protocol: Union[Literal[False], ProxyProtocolSchema] = False
     listen: List[ListenSchema] = [
-        ListenSchema({"interface": "127.0.0.1"}),
-        ListenSchema({"interface": "::1", "freebind": True}),
+        ListenSchema({"interface": ["127.0.0.1"]}),
+        ListenSchema({"interface": ["::1"], "freebind": True}),
     ]
index 427e4a20a2da6e41573a5f0a8132f54d5efb7357..256092a1d1b8487d913b6608639fd236ab12e32b 100644 (file)
@@ -17,7 +17,6 @@ from .types import (
     IPv4Address,
     IPv6Address,
     IPv6Network96,
-    ListOrSingle,
     Percent,
     PortNumber,
     SizeUnit,
@@ -44,7 +43,6 @@ __all__ = [
     "IPv4Address",
     "IPv6Address",
     "IPv6Network96",
-    "ListOrSingle",
     "Percent",
     "PortNumber",
     "SizeUnit",
index 02ef7c7d0a95e6289f18324123bc5cc5d4644b74..d0bc21a97658e3ee1cf8030e88bea3987566e850 100644 (file)
@@ -5,9 +5,8 @@ from typing import Any, Dict, List, Optional, Type, TypeVar, Union
 from knot_resolver_manager.datamodel.types.base_types import IntRangeBase, PatternBase, StrBase, UnitBase
 from knot_resolver_manager.utils.modeling import BaseValueType
 
-_ElementType = TypeVar("_ElementType")
-
-ListOrSingle = Union[List[_ElementType], _ElementType]
+_InnerType = TypeVar("_InnerType")
+ListOrSingle = List[_InnerType]
 
 
 class IntNonNegative(IntRangeBase):