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, self,
volume, volume,
job, job,
[ FolderMoveNames.default_foldermoves(self),
FolderMoveNames(
name=Bitwarden.get_foldername(folder),
bind_location=folder,
group="vaultwarden",
owner="vaultwarden",
)
for folder in Bitwarden.get_folders()
],
"bitwarden", "bitwarden",
) )

View file

@ -34,6 +34,15 @@ class FolderMoveNames(BaseModel):
def get_foldername(path: str) -> str: def get_foldername(path: str) -> str:
return path.split("/")[-1] 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() @huey.task()
def move_service( def move_service(

View file

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

View file

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

View file

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

View file

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