core: Replace legacy INI config system with Pydantic-based TOML configuration.
This is a huge configuration refactoring. The configuration system now uses Pydantic settings, with better validation, better support for environment variables and other goodies. The main config files now use TOML instead of INI, this allow for better handling of complex types, notably dict. Plugins, components and frontends can declare their config settings in a class which will be imported dynamically.
This commit is contained in:
parent
f3f40848b3
commit
6a7b7bc36a
1 changed files with 1392 additions and 1011 deletions
|
|
@ -17,6 +17,8 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pydantic import Field
|
||||
from libervia.backend import G
|
||||
from libervia.backend.core.i18n import _
|
||||
from libervia.backend.core.constants import Const as C
|
||||
from libervia.backend.core.log import getLogger
|
||||
|
|
@ -26,6 +28,8 @@ from twisted.internet import reactor, protocol, defer
|
|||
from twisted.words.protocols.jabber import jid
|
||||
from twisted.conch.manhole import ColoredManhole
|
||||
|
||||
from libervia.backend.tools.config import PluginSettings
|
||||
|
||||
log = getLogger(__name__)
|
||||
|
||||
PLUGIN_INFO = {
|
||||
|
|
@ -40,11 +44,18 @@ PLUGIN_INFO = {
|
|||
}
|
||||
|
||||
|
||||
class PluginManholeSettings(PluginSettings, plugin_info=PLUGIN_INFO):
|
||||
dangerous_manhole_debug_port: int = Field(
|
||||
default=0, description="Debug port for manhole"
|
||||
)
|
||||
|
||||
|
||||
class Manhole(object):
|
||||
|
||||
def __init__(self, host):
|
||||
self.host = host
|
||||
port = int(host.memory.config_get(None, "manhole_debug_dangerous_port_int", 0))
|
||||
settings = G.config.get_settings(PluginManholeSettings)
|
||||
port = settings.dangerous_manhole_debug_port
|
||||
if port:
|
||||
self.start_manhole(port)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue