Skip to content

Commit 6d8e60f

Browse files
authored
Merge branch 'master' into fix-aerich-migrations
2 parents c09fce8 + 32abd0e commit 6d8e60f

128 files changed

Lines changed: 1021 additions & 241 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 0 additions & 1 deletion

conftest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
from tortoise import Tortoise
1212
from tortoise.contrib.fastapi import RegisterTortoise
1313

14-
from goosebit import app
15-
from goosebit.auth.permissions import GOOSEBIT_PERMISSIONS
16-
from goosebit.db.models import UpdateModeEnum, UpdateStateEnum
17-
from goosebit.settings import PWD_CXT # type: ignore[attr-defined]
14+
# Configuring rauc_compatible_pattern for tests/unit/updates/rauc/test_swdesc.py here, as we do not want to have it set
15+
# in goosebit.yaml.
16+
os.environ["GOOSEBIT_RAUC_COMPATIBLE_PATTERN"] = r"^(?P<hw_boardname>.+?)(-(?P<hw_revision>\w*[\d.]+\w*))?$"
17+
18+
from goosebit import app # noqa: E402
19+
from goosebit.auth.permissions import GOOSEBIT_PERMISSIONS # noqa: E402
20+
from goosebit.db.models import UpdateModeEnum, UpdateStateEnum # noqa: E402
21+
from goosebit.settings import PWD_CXT # type: ignore[attr-defined] # noqa: E402
1822

1923
# Configure logging
2024
logging.basicConfig(level=logging.WARN)

goosebit.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ poll_time: 00:01:00
5959
# Defaults to a randomized value. If this value is not set, user sessions will not persist when app restarts.
6060
#secret_key: my_very_top_secret_key123
6161

62+
# Regular expression to extract board name and revision from RAUC compatible string.
63+
# HW revision support is disabled by default when using RAUC.
64+
# By uncommenting the following line, the last part of the compatible string, separated by a hyphen, will be
65+
# interpreted as the HW revision, e.g.: myboard-rev1.0a
66+
#rauc_compatible_pattern: ^(?P<hw_boardname>.+?)(-(?P<hw_revision>\w*[\d.]+\w*))?$
67+
6268
# A list of installed plugins that you want to enable in gooseBit
6369
#plugins:
6470
# - goosebit_simple_stats

goosebit/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ async def lifespan(_: FastAPI) -> AsyncGenerator[None, None]:
6262
}
6363
],
6464
)
65-
app.include_router(updater.router) # type: ignore[attr-defined]
65+
if isinstance(config.tenant, list):
66+
for tenant in config.tenant:
67+
app.include_router(updater.router, prefix=f"/{tenant}") # type: ignore[attr-defined]
68+
elif isinstance(config.tenant, str):
69+
app.include_router(updater.router, prefix=f"/{config.tenant}") # type: ignore[attr-defined]
6670
app.include_router(ui.router) # type: ignore[attr-defined]
6771
app.include_router(api.router) # type: ignore[attr-defined]
6872
app.mount("/static", static, name="static")

goosebit/schema/software.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
from __future__ import annotations
22

3-
from urllib.parse import unquote, urlparse
3+
from urllib.parse import unquote, urlparse, urlunparse
44
from urllib.request import url2pathname
55

66
from anyio import Path
77
from pydantic import BaseModel, ConfigDict, Field, computed_field
88

99

10+
def mask_url_password(url: str) -> str:
11+
"""Mask password in URL for display purposes."""
12+
parsed = urlparse(url)
13+
if parsed.password:
14+
# Reconstruct netloc with masked password
15+
if parsed.port:
16+
netloc = f"{parsed.username}:***@{parsed.hostname}:{parsed.port}"
17+
else:
18+
netloc = f"{parsed.username}:***@{parsed.hostname}"
19+
return urlunparse(parsed._replace(netloc=netloc))
20+
return url
21+
22+
1023
class HardwareSchema(BaseModel):
1124
model_config = ConfigDict(from_attributes=True)
1225

@@ -39,4 +52,4 @@ def name(self) -> str:
3952
if self.local:
4053
return self.path.name
4154
else:
42-
return self.uri
55+
return mask_url_password(self.uri)

goosebit/settings/schema.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class GooseBitSettings(BaseSettings):
7676
config_file: Path | None = None
7777

7878
port: int = 60053 # GOOSE
79-
tenant: str = "DEFAULT"
79+
tenant: str | list = "DEFAULT"
8080

8181
poll_time: str = "00:01:00"
8282

@@ -101,6 +101,8 @@ class GooseBitSettings(BaseSettings):
101101

102102
track_device_ip: bool = True
103103

104+
rauc_compatible_pattern: str | None = None
105+
104106
@field_validator("secret_key", mode="before")
105107
@classmethod
106108
def import_secret_key(cls, v: Any) -> OctKey:
13.7 KB
15.1 KB
3.82 KB
37.6 KB

0 commit comments

Comments
 (0)