Initial ABSDEV deployment framework development preview
ABSDEV Framework CI / framework-validation (push) Canceled after 0s

This commit is contained in:
2026-11-26 11:35:28 +00:00
commit d6e2317016
76 changed files with 20260 additions and 0 deletions
View File
View File
+92
View File
@@ -0,0 +1,92 @@
"""MySQL database command construction."""
from core.database import DatabaseAdapter
class MySQLAdapter(DatabaseAdapter):
backup_extension = ".sql"
client_configuration = (
"--defaults-file=/run/secrets/absdev-client.cnf"
)
def connection_arguments(self):
return [
"--protocol=TCP",
f"--host={self.database['host']}",
f"--port={self.database['port']}",
f"--user={self.database['username']}",
]
def query_command(self, query):
return (
self.docker_exec()
+ [
"mysql",
self.client_configuration,
]
+ self.connection_arguments()
+ [
"--batch",
"--skip-column-names",
f"--database={self.database['name']}",
"--execute",
query,
]
)
def ping_command(self):
return self.query_command("SELECT 1")
def version_command(self):
return self.query_command("SELECT VERSION()")
def identity_command(self):
return self.query_command(
"SELECT DATABASE(), CURRENT_USER(), @@server_uuid"
)
def backup_command(self):
return (
self.docker_exec()
+ [
"mysqldump",
self.client_configuration,
]
+ self.connection_arguments()
+ [
"--single-transaction",
"--quick",
"--no-tablespaces",
"--skip-lock-tables",
"--set-gtid-purged=OFF",
"--hex-blob",
"--triggers",
"--routines",
"--events",
self.database["name"],
]
)
def restore_command(self, target):
target = self.validate_restore_target(target)
return (
self.docker_exec(interactive=True)
+ [
"mysql",
self.client_configuration,
]
+ self.connection_arguments()
+ [
f"--database={target}",
]
)
View File
+86
View File
@@ -0,0 +1,86 @@
"""PostgreSQL database command construction."""
from core.database import DatabaseAdapter
class PostgreSQLAdapter(DatabaseAdapter):
backup_extension = ".dump"
def client_command(
self,
executable,
interactive=False,
):
return (
self.docker_exec(interactive=interactive)
+ [
"env",
"PGPASSFILE=/run/secrets/absdev-pgpass",
executable,
"--no-password",
f"--host={self.database['host']}",
f"--port={self.database['port']}",
f"--username={self.database['username']}",
]
)
def query_command(self, query):
return (
self.client_command("psql")
+ [
"--no-psqlrc",
"--tuples-only",
"--no-align",
"--set=ON_ERROR_STOP=1",
f"--dbname={self.database['name']}",
"--command",
query,
]
)
def ping_command(self):
return self.query_command("SELECT 1")
def version_command(self):
return self.query_command("SHOW server_version")
def identity_command(self):
return self.query_command(
"SELECT current_database(), current_user"
)
def backup_command(self):
return (
self.client_command("pg_dump")
+ [
"--format=custom",
"--no-owner",
"--no-privileges",
f"--dbname={self.database['name']}",
]
)
def restore_command(self, target):
target = self.validate_restore_target(target)
return (
self.client_command(
"pg_restore",
interactive=True,
)
+ [
"--exit-on-error",
"--no-owner",
"--no-privileges",
"--single-transaction",
f"--dbname={target}",
]
)