mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-09-07 18:36:56 +00:00
refactor: Change gitea to Forgejo
This commit is contained in:
parent
5602c96056
commit
7522c2d796
|
@ -6,7 +6,7 @@ import shutil
|
|||
from pydantic import BaseModel
|
||||
from selfprivacy_api.jobs import Job, JobStatus, Jobs
|
||||
from selfprivacy_api.services.bitwarden import Bitwarden
|
||||
from selfprivacy_api.services.gitea import Gitea
|
||||
from selfprivacy_api.services.forgejo import Forgejo
|
||||
from selfprivacy_api.services.mailserver import MailServer
|
||||
from selfprivacy_api.services.nextcloud import Nextcloud
|
||||
from selfprivacy_api.services.pleroma import Pleroma
|
||||
|
@ -230,7 +230,7 @@ def migrate_to_binds(config: BindMigrationConfig, job: Job):
|
|||
status_text="Migrating Gitea.",
|
||||
)
|
||||
|
||||
Gitea().stop()
|
||||
Forgejo().stop()
|
||||
|
||||
if not pathlib.Path("/volumes/sda1/gitea").exists():
|
||||
if not pathlib.Path("/volumes/sdb/gitea").exists():
|
||||
|
@ -241,7 +241,7 @@ def migrate_to_binds(config: BindMigrationConfig, job: Job):
|
|||
group="gitea",
|
||||
)
|
||||
|
||||
Gitea().start()
|
||||
Forgejo().start()
|
||||
|
||||
# Perform migration of Mail server
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
import typing
|
||||
from selfprivacy_api.services.bitwarden import Bitwarden
|
||||
from selfprivacy_api.services.gitea import Gitea
|
||||
from selfprivacy_api.services.forgejo import Forgejo
|
||||
from selfprivacy_api.services.jitsimeet import JitsiMeet
|
||||
from selfprivacy_api.services.mailserver import MailServer
|
||||
from selfprivacy_api.services.nextcloud import Nextcloud
|
||||
|
@ -13,7 +13,7 @@ import selfprivacy_api.utils.network as network_utils
|
|||
|
||||
services: list[Service] = [
|
||||
Bitwarden(),
|
||||
Gitea(),
|
||||
Forgejo(),
|
||||
MailServer(),
|
||||
Nextcloud(),
|
||||
Pleroma(),
|
||||
|
|
|
@ -7,31 +7,34 @@ from selfprivacy_api.utils import get_domain
|
|||
|
||||
from selfprivacy_api.utils.systemd import get_service_status
|
||||
from selfprivacy_api.services.service import Service, ServiceStatus
|
||||
from selfprivacy_api.services.gitea.icon import GITEA_ICON
|
||||
from selfprivacy_api.services.forgejo.icon import FORGEJO_ICON
|
||||
|
||||
|
||||
class Gitea(Service):
|
||||
"""Class representing Gitea service"""
|
||||
class Forgejo(Service):
|
||||
"""Class representing Forgejo service.
|
||||
|
||||
Previously was Gitea, so some IDs are still called gitea for compatibility.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def get_id() -> str:
|
||||
"""Return service id."""
|
||||
"""Return service id. For compatibility keep in gitea."""
|
||||
return "gitea"
|
||||
|
||||
@staticmethod
|
||||
def get_display_name() -> str:
|
||||
"""Return service display name."""
|
||||
return "Gitea"
|
||||
return "Forgejo"
|
||||
|
||||
@staticmethod
|
||||
def get_description() -> str:
|
||||
"""Return service description."""
|
||||
return "Gitea is a Git forge."
|
||||
return "Forgejo is a Git forge."
|
||||
|
||||
@staticmethod
|
||||
def get_svg_icon() -> str:
|
||||
"""Read SVG icon from file and return it as base64 encoded string."""
|
||||
return base64.b64encode(GITEA_ICON.encode("utf-8")).decode("utf-8")
|
||||
return base64.b64encode(FORGEJO_ICON.encode("utf-8")).decode("utf-8")
|
||||
|
||||
@staticmethod
|
||||
def get_url() -> Optional[str]:
|
||||
|
@ -65,19 +68,19 @@ class Gitea(Service):
|
|||
Return code 3 means service is stopped.
|
||||
Return code 4 means service is off.
|
||||
"""
|
||||
return get_service_status("gitea.service")
|
||||
return get_service_status("forgejo.service")
|
||||
|
||||
@staticmethod
|
||||
def stop():
|
||||
subprocess.run(["systemctl", "stop", "gitea.service"])
|
||||
subprocess.run(["systemctl", "stop", "forgejo.service"])
|
||||
|
||||
@staticmethod
|
||||
def start():
|
||||
subprocess.run(["systemctl", "start", "gitea.service"])
|
||||
subprocess.run(["systemctl", "start", "forgejo.service"])
|
||||
|
||||
@staticmethod
|
||||
def restart():
|
||||
subprocess.run(["systemctl", "restart", "gitea.service"])
|
||||
subprocess.run(["systemctl", "restart", "forgejo.service"])
|
||||
|
||||
@staticmethod
|
||||
def get_configuration():
|
||||
|
@ -93,4 +96,5 @@ class Gitea(Service):
|
|||
|
||||
@staticmethod
|
||||
def get_folders() -> List[str]:
|
||||
"""The data folder is still called gitea for compatibility."""
|
||||
return ["/var/lib/gitea"]
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
|
@ -1,4 +1,4 @@
|
|||
GITEA_ICON = """
|
||||
FORGEJO_ICON = """
|
||||
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M2.60007 10.5899L8.38007 4.79995L10.0701 6.49995C9.83007 7.34995 10.2201 8.27995 11.0001 8.72995V14.2699C10.4001 14.6099 10.0001 15.2599 10.0001 15.9999C10.0001 16.5304 10.2108 17.0391 10.5859 17.4142C10.9609 17.7892 11.4696 17.9999 12.0001 17.9999C12.5305 17.9999 13.0392 17.7892 13.4143 17.4142C13.7894 17.0391 14.0001 16.5304 14.0001 15.9999C14.0001 15.2599 13.6001 14.6099 13.0001 14.2699V9.40995L15.0701 11.4999C15.0001 11.6499 15.0001 11.8199 15.0001 11.9999C15.0001 12.5304 15.2108 13.0391 15.5859 13.4142C15.9609 13.7892 16.4696 13.9999 17.0001 13.9999C17.5305 13.9999 18.0392 13.7892 18.4143 13.4142C18.7894 13.0391 19.0001 12.5304 19.0001 11.9999C19.0001 11.4695 18.7894 10.9608 18.4143 10.5857C18.0392 10.2107 17.5305 9.99995 17.0001 9.99995C16.8201 9.99995 16.6501 9.99995 16.5001 10.0699L13.9301 7.49995C14.1901 6.56995 13.7101 5.54995 12.7801 5.15995C12.3501 4.99995 11.9001 4.95995 11.5001 5.06995L9.80007 3.37995L10.5901 2.59995C11.3701 1.80995 12.6301 1.80995 13.4101 2.59995L21.4001 10.5899C22.1901 11.3699 22.1901 12.6299 21.4001 13.4099L13.4101 21.3999C12.6301 22.1899 11.3701 22.1899 10.5901 21.3999L2.60007 13.4099C1.81007 12.6299 1.81007 11.3699 2.60007 10.5899Z" fill="black"/>
|
||||
</svg>
|
|
@ -2,7 +2,7 @@ import pytest
|
|||
|
||||
from selfprivacy_api.services.service import ServiceStatus
|
||||
from selfprivacy_api.services.bitwarden import Bitwarden
|
||||
from selfprivacy_api.services.gitea import Gitea
|
||||
from selfprivacy_api.services.forgejo import Forgejo
|
||||
from selfprivacy_api.services.mailserver import MailServer
|
||||
from selfprivacy_api.services.nextcloud import Nextcloud
|
||||
from selfprivacy_api.services.ocserv import Ocserv
|
||||
|
@ -22,7 +22,7 @@ def call_args_asserts(mocked_object):
|
|||
"dovecot2.service",
|
||||
"postfix.service",
|
||||
"vaultwarden.service",
|
||||
"gitea.service",
|
||||
"forgejo.service",
|
||||
"phpfpm-nextcloud.service",
|
||||
"ocserv.service",
|
||||
"pleroma.service",
|
||||
|
@ -77,7 +77,7 @@ def mock_popen_systemctl_service_not_ok(mocker):
|
|||
def test_systemctl_ok(mock_popen_systemctl_service_ok):
|
||||
assert MailServer.get_status() == ServiceStatus.ACTIVE
|
||||
assert Bitwarden.get_status() == ServiceStatus.ACTIVE
|
||||
assert Gitea.get_status() == ServiceStatus.ACTIVE
|
||||
assert Forgejo.get_status() == ServiceStatus.ACTIVE
|
||||
assert Nextcloud.get_status() == ServiceStatus.ACTIVE
|
||||
assert Ocserv.get_status() == ServiceStatus.ACTIVE
|
||||
assert Pleroma.get_status() == ServiceStatus.ACTIVE
|
||||
|
@ -87,7 +87,7 @@ def test_systemctl_ok(mock_popen_systemctl_service_ok):
|
|||
def test_systemctl_failed_service(mock_popen_systemctl_service_not_ok):
|
||||
assert MailServer.get_status() == ServiceStatus.FAILED
|
||||
assert Bitwarden.get_status() == ServiceStatus.FAILED
|
||||
assert Gitea.get_status() == ServiceStatus.FAILED
|
||||
assert Forgejo.get_status() == ServiceStatus.FAILED
|
||||
assert Nextcloud.get_status() == ServiceStatus.FAILED
|
||||
assert Ocserv.get_status() == ServiceStatus.FAILED
|
||||
assert Pleroma.get_status() == ServiceStatus.FAILED
|
||||
|
|
Loading…
Reference in a new issue