From 4d898f4ee803170ba66eb05e146fac7c814392c8 Mon Sep 17 00:00:00 2001 From: dettlaff Date: Sun, 16 Jun 2024 10:39:39 +0400 Subject: [PATCH] feat: add migration for services flake --- .../migrations/update_services_flake_list.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 selfprivacy_api/migrations/update_services_flake_list.py diff --git a/selfprivacy_api/migrations/update_services_flake_list.py b/selfprivacy_api/migrations/update_services_flake_list.py new file mode 100644 index 0000000..8d3b8e8 --- /dev/null +++ b/selfprivacy_api/migrations/update_services_flake_list.py @@ -0,0 +1,34 @@ +from selfprivacy_api.migrations.migration import Migration +from selfprivacy_api.jobs import JobStatus, Jobs + +from selfprivacy_api.services.flake_service_manager import FlakeServiceManager + +CORRECT_SERVICES_LIST = { + "bitwarden": "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/bitwarden", + "gitea": "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/gitea", + "jitsi-meet": "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/jitsi-meet", + "nextcloud": "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/nextcloud", + "ocserv": "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/ocserv", + "pleroma": "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/pleroma", + "simple-nixos-mailserver": "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/simple-nixos-mailserver", + "roundcube": "git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes&dir=sp-modules/roundcube", +} + + +class UpdateServicesFlakeList(Migration): + """Check if all required services are in the flake list""" + + def get_migration_name(self): + return "update_services_flake_list" + + def get_migration_description(self): + return "Check if all required services are in the flake list" + + def is_migration_needed(self): + with FlakeServiceManager: + if not manager.services == CORRECT_SERVICES_LIST: + return True + + def migrate(self): + with FlakeServiceManager: + manager.services = CORRECT_SERVICES_LIST