refactor(services): use fully generic foldermoves

This commit is contained in:
Houkime 2023-04-19 12:43:47 +00:00
parent dde86725b9
commit 65acd3173a
6 changed files with 18 additions and 54 deletions

View file

@ -154,15 +154,7 @@ class Bitwarden(Service):
self,
volume,
job,
[
FolderMoveNames(
name=Bitwarden.get_foldername(folder),
bind_location=folder,
group="vaultwarden",
owner="vaultwarden",
)
for folder in Bitwarden.get_folders()
],
FolderMoveNames.default_foldermoves(self),
"bitwarden",
)

View file

@ -34,6 +34,15 @@ class FolderMoveNames(BaseModel):
def get_foldername(path: str) -> str:
return path.split("/")[-1]
@staticmethod
def default_foldermoves(service: Service):
return (
[
FolderMoveNames.from_owned_path(folder)
for folder in service.get_owned_folders()
],
)
@huey.task()
def move_service(

View file

@ -148,15 +148,7 @@ class Gitea(Service):
self,
volume,
job,
[
FolderMoveNames(
name=Gitea.get_foldername(folder),
bind_location=folder,
group="gitea",
owner="gitea",
)
for folder in Gitea.get_folders()
],
FolderMoveNames.default_foldermoves(self),
"gitea",
)

View file

@ -37,6 +37,10 @@ class MailServer(Service):
def get_svg_icon() -> str:
return base64.b64encode(MAILSERVER_ICON.encode("utf-8")).decode("utf-8")
@staticmethod
def get_user() -> str:
return "virtualMail"
@staticmethod
def get_url() -> typing.Optional[str]:
"""Return service url."""
@ -158,20 +162,7 @@ class MailServer(Service):
self,
volume,
job,
[
FolderMoveNames(
name="vmail",
bind_location="/var/vmail",
group="virtualMail",
owner="virtualMail",
),
FolderMoveNames(
name="sieve",
bind_location="/var/sieve",
group="virtualMail",
owner="virtualMail",
),
],
FolderMoveNames.default_foldermoves(self),
"mailserver",
)

View file

@ -152,14 +152,7 @@ class Nextcloud(Service):
self,
volume,
job,
[
FolderMoveNames(
name="nextcloud",
bind_location="/var/lib/nextcloud",
owner="nextcloud",
group="nextcloud",
),
],
FolderMoveNames.default_foldermoves(self),
"nextcloud",
)
return job

View file

@ -150,20 +150,7 @@ class Pleroma(Service):
self,
volume,
job,
[
FolderMoveNames(
name="pleroma",
bind_location="/var/lib/pleroma",
owner="pleroma",
group="pleroma",
),
FolderMoveNames(
name="postgresql",
bind_location="/var/lib/postgresql",
owner="postgres",
group="postgres",
),
],
FolderMoveNames.default_foldermoves(self),
"pleroma",
)
return job