Core outline
This commit is contained in:
parent
eeada83132
commit
2d3699ad00
7 changed files with 47 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,6 +1,7 @@
|
||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
uv.lock
|
uv.lock
|
||||||
|
**/*.kdbx*
|
||||||
|
|
||||||
__pycache__/
|
__pycache__/
|
||||||
**/dist/
|
**/dist/
|
||||||
|
|
|
||||||
0
app/core/__init__.py
Normal file
0
app/core/__init__.py
Normal file
28
app/core/core.py
Normal file
28
app/core/core.py
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
from app.model.healthcheck import HealthCheck
|
||||||
|
from app.services import DockerService, GitService, Passwords
|
||||||
|
|
||||||
|
|
||||||
|
class WebhookProcessor:
|
||||||
|
def __init__(self):
|
||||||
|
try:
|
||||||
|
self._docker = DockerService()
|
||||||
|
except Exception as e:
|
||||||
|
self._docker = None
|
||||||
|
print(e)
|
||||||
|
try:
|
||||||
|
self._git = GitService()
|
||||||
|
except Exception as e:
|
||||||
|
self._git = None
|
||||||
|
print(f"{type(e).__name__}: {e}")
|
||||||
|
try:
|
||||||
|
self._keepass = Passwords()
|
||||||
|
except Exception as e:
|
||||||
|
self._keepass = None
|
||||||
|
print(e)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def health(self) -> HealthCheck:
|
||||||
|
return HealthCheck(
|
||||||
|
self._docker is not None and self._git is not None and self._keepass is not None,
|
||||||
|
f"Docker: {self._docker is not None}, Git: {self._git is not None}, KeePass: {self._keepass is not None}"
|
||||||
|
)
|
||||||
|
|
@ -4,6 +4,7 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||||
|
|
||||||
from app.api.v1 import router as api_v1_router
|
from app.api.v1 import router as api_v1_router
|
||||||
from app.config import get_settings
|
from app.config import get_settings
|
||||||
|
from app.core.core import WebhookProcessor
|
||||||
|
|
||||||
# Inicjalizacja Jinja2
|
# Inicjalizacja Jinja2
|
||||||
templates_env = Environment(
|
templates_env = Environment(
|
||||||
|
|
@ -15,6 +16,10 @@ app = FastAPI(title="Karl", version="0.1.0")
|
||||||
|
|
||||||
# Rejestracja routera API pod /api/v1
|
# Rejestracja routera API pod /api/v1
|
||||||
app.include_router(api_v1_router, prefix="/api/v1", tags=["v1"])
|
app.include_router(api_v1_router, prefix="/api/v1", tags=["v1"])
|
||||||
|
# app.add_event_handler()
|
||||||
|
|
||||||
|
webhook_service = WebhookProcessor()
|
||||||
|
print(webhook_service.health)
|
||||||
|
|
||||||
|
|
||||||
# Przykładowy endpoint HTML
|
# Przykładowy endpoint HTML
|
||||||
|
|
|
||||||
7
app/model/healthcheck.py
Normal file
7
app/model/healthcheck.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
from dataclasses import dataclass
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class HealthCheck:
|
||||||
|
healthy: bool
|
||||||
|
message: str
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
from .containers import DockerService
|
||||||
|
from .passwords import Passwords
|
||||||
|
from .vcs import GitService
|
||||||
|
|
||||||
|
__all__ = ["GitService", "Passwords", "DockerService"]
|
||||||
1
config/secret.txt
Normal file
1
config/secret.txt
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
supersecret
|
||||||
Loading…
Add table
Add a link
Reference in a new issue