applicactions: fix applications:
This patch fix application configuration parsing. Peertube and Weblate can be started again.
This commit is contained in:
parent
f17fee4802
commit
c31b6e207c
4 changed files with 33 additions and 13 deletions
|
|
@ -51,7 +51,7 @@ override:
|
||||||
PEERTUBE_DB_PASSWORD: &db_password !libervia_generate_pwd {name: db}
|
PEERTUBE_DB_PASSWORD: &db_password !libervia_generate_pwd {name: db}
|
||||||
PEERTUBE_DB_SSL: "false"
|
PEERTUBE_DB_SSL: "false"
|
||||||
PEERTUBE_DB_HOSTNAME: "postgres"
|
PEERTUBE_DB_HOSTNAME: "postgres"
|
||||||
PEERTUBE_WEBSERVER_HOSTNAME: !libervia_conf ["application peertube", "hostname"]
|
PEERTUBE_WEBSERVER_HOSTNAME: !libervia_conf ["application.peertube", "hostname"]
|
||||||
PEERTUBE_TRUST_PROXY: '["127.0.0.1", "loopback", "172.18.0.0/16"]'
|
PEERTUBE_TRUST_PROXY: '["127.0.0.1", "loopback", "172.18.0.0/16"]'
|
||||||
PEERTUBE_SECRET: !libervia_generate_pwd {name: secret}
|
PEERTUBE_SECRET: !libervia_generate_pwd {name: secret}
|
||||||
PEERTUBE_SMTP_HOSTNAME: !libervia_conf ["email", "server"]
|
PEERTUBE_SMTP_HOSTNAME: !libervia_conf ["email", "server"]
|
||||||
|
|
@ -59,7 +59,7 @@ override:
|
||||||
PEERTUBE_SMTP_PASSWORD: !libervia_conf ["email", "password"]
|
PEERTUBE_SMTP_PASSWORD: !libervia_conf ["email", "password"]
|
||||||
PEERTUBE_SMTP_DISABLE_STARTTLS: !libervia_conf ["email", "starttls", "false", "not"]
|
PEERTUBE_SMTP_DISABLE_STARTTLS: !libervia_conf ["email", "starttls", "false", "not"]
|
||||||
PEERTUBE_SMTP_PORT: !libervia_conf ["email", "port"]
|
PEERTUBE_SMTP_PORT: !libervia_conf ["email", "port"]
|
||||||
PEERTUBE_SMTP_FROM: !libervia_conf ["application peertube", "email_from", "peertube@example.com"]
|
PEERTUBE_SMTP_FROM: !libervia_conf ["application.peertube", "email_from", "peertube@example.com"]
|
||||||
PEERTUBE_SMTP_TLS: "false"
|
PEERTUBE_SMTP_TLS: "false"
|
||||||
PEERTUBE_ADMIN_EMAIL: !libervia_conf ["common", "email_admins_list", "", "first"]
|
PEERTUBE_ADMIN_EMAIL: !libervia_conf ["common", "email_admins_list", "", "first"]
|
||||||
PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL_PUBLIC: "public-read"
|
PEERTUBE_OBJECT_STORAGE_UPLOAD_ACL_PUBLIC: "public-read"
|
||||||
|
|
|
||||||
|
|
@ -14,15 +14,15 @@ override:
|
||||||
environment:
|
environment:
|
||||||
WEBLATE_DEBUG: 0
|
WEBLATE_DEBUG: 0
|
||||||
WEBLATE_URL_PREFIX: !libervia_param [url_prefix, /weblate]
|
WEBLATE_URL_PREFIX: !libervia_param [url_prefix, /weblate]
|
||||||
WEBLATE_EMAIL_HOST: !libervia_conf ["application weblate", "email_server"]
|
WEBLATE_EMAIL_HOST: !libervia_conf ["application.weblate", "email_server"]
|
||||||
WEBLATE_EMAIL_HOST_USER: !libervia_conf ["application weblate", "email_username"]
|
WEBLATE_EMAIL_HOST_USER: !libervia_conf ["application.weblate", "email_username"]
|
||||||
WEBLATE_EMAIL_HOST_PASSWORD: !libervia_conf ["application weblate", "email_password"]
|
WEBLATE_EMAIL_HOST_PASSWORD: !libervia_conf ["application.weblate", "email_password"]
|
||||||
WEBLATE_SERVER_EMAIL: !libervia_conf ["application weblate", "email_from", "weblate@example.com"]
|
WEBLATE_SERVER_EMAIL: !libervia_conf ["application.weblate", "email_from", "weblate@example.com"]
|
||||||
WEBLATE_DEFAULT_FROM_EMAIL: !libervia_conf ["application weblate", "email_from", "weblate@example.com"]
|
WEBLATE_DEFAULT_FROM_EMAIL: !libervia_conf ["application.weblate", "email_from", "weblate@example.com"]
|
||||||
WEBLATE_SITE_DOMAIN: !libervia_conf ["application weblate", "public_url"]
|
WEBLATE_SITE_DOMAIN: !libervia_conf ["application.weblate", "public_url"]
|
||||||
WEBLATE_ADMIN_PASSWORD: !libervia_generate_pwd {name: admin}
|
WEBLATE_ADMIN_PASSWORD: !libervia_generate_pwd {name: admin}
|
||||||
WEBLATE_ADMIN_EMAIL: !libervia_conf ["common", "email_admins_list", "", "first"]
|
WEBLATE_ADMIN_EMAIL: !libervia_conf ["common", "email_admins_list", "", "first"]
|
||||||
WEBLATE_ENABLE_HTTPS: !libervia_conf ["application weblate", "enable_https", "1"]
|
WEBLATE_ENABLE_HTTPS: !libervia_conf ["application.weblate", "enable_https", "1"]
|
||||||
volumes:
|
volumes:
|
||||||
- ./settings-override.py:/app/data/settings-override.py:ro
|
- ./settings-override.py:/app/data/settings-override.py:ro
|
||||||
expose:
|
expose:
|
||||||
|
|
|
||||||
|
|
@ -150,7 +150,7 @@ class AppManager:
|
||||||
)
|
)
|
||||||
data["_instance_dir_obj"].cleanup()
|
data["_instance_dir_obj"].cleanup()
|
||||||
|
|
||||||
def _libervia_conf_constr(self, loader, node) -> str:
|
def _libervia_conf_constr(self, loader, node) -> str|None:
|
||||||
"""Get a value from Libervia configuration
|
"""Get a value from Libervia configuration
|
||||||
|
|
||||||
A list is expected with either "name" of a config parameter, a one or more of
|
A list is expected with either "name" of a config parameter, a one or more of
|
||||||
|
|
@ -178,7 +178,21 @@ class AppManager:
|
||||||
"is expected"
|
"is expected"
|
||||||
)
|
)
|
||||||
|
|
||||||
value = getattr(getattr(G.config, section), name) or default
|
try:
|
||||||
|
if section.startswith("application."):
|
||||||
|
key = section[12:].strip()
|
||||||
|
if not key:
|
||||||
|
raise ValueError("Invalid configuration section: {section!r}}")
|
||||||
|
value = G.config.application.get(key, {}).get(name, default)
|
||||||
|
else:
|
||||||
|
value = getattr(getattr(G.config, section), name) or default
|
||||||
|
except (AttributeError, KeyError):
|
||||||
|
from pudb import set_trace; set_trace()
|
||||||
|
raise ValueError(
|
||||||
|
f"Invalid configuration request: {section=}, {name=}, {default=}, "
|
||||||
|
f"{filter=}"
|
||||||
|
)
|
||||||
|
|
||||||
# FIXME: "public_url" is used only here and doesn't take multi-sites into account
|
# FIXME: "public_url" is used only here and doesn't take multi-sites into account
|
||||||
if name == "public_url" and (not value or value.startswith("http")):
|
if name == "public_url" and (not value or value.startswith("http")):
|
||||||
if not value:
|
if not value:
|
||||||
|
|
@ -201,9 +215,11 @@ class AppManager:
|
||||||
if filter_ is None:
|
if filter_ is None:
|
||||||
pass
|
pass
|
||||||
elif filter_ == "first":
|
elif filter_ == "first":
|
||||||
|
if not value:
|
||||||
|
raise ValueError("Invalid value: {value!r}")
|
||||||
value = value[0]
|
value = value[0]
|
||||||
elif filter_ == "not":
|
elif filter_ == "not":
|
||||||
value = C.bool(value)
|
assert isinstance(value, bool)
|
||||||
value = C.bool_const(not value).lower()
|
value = C.bool_const(not value).lower()
|
||||||
else:
|
else:
|
||||||
raise ValueError(f"unmanaged filter: {filter_}")
|
raise ValueError(f"unmanaged filter: {filter_}")
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from socket import getfqdn
|
from socket import getfqdn
|
||||||
from typing import Annotated, Literal, TypeVar, cast
|
from typing import Annotated, Any, Literal, TypeVar, cast
|
||||||
|
|
||||||
from pydantic import (
|
from pydantic import (
|
||||||
AfterValidator,
|
AfterValidator,
|
||||||
|
|
@ -384,6 +384,10 @@ class Settings(BaseSettings):
|
||||||
email: EmailSettings = Field(default_factory=EmailSettings)
|
email: EmailSettings = Field(default_factory=EmailSettings)
|
||||||
tls: TLSSettings = Field(default_factory=TLSSettings)
|
tls: TLSSettings = Field(default_factory=TLSSettings)
|
||||||
tor: TorSettings = Field(default_factory=TorSettings)
|
tor: TorSettings = Field(default_factory=TorSettings)
|
||||||
|
application: dict[str, dict[str, str]] = Field(
|
||||||
|
default_factory=dict,
|
||||||
|
description="Application specific settings, used by app manager."
|
||||||
|
)
|
||||||
plugin: dict = Field(default_factory=dict, description="Plugin specific settings.")
|
plugin: dict = Field(default_factory=dict, description="Plugin specific settings.")
|
||||||
component: dict = Field(
|
component: dict = Field(
|
||||||
default_factory=dict, description="Component specific settings."
|
default_factory=dict, description="Component specific settings."
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue