adding docker functions

This commit is contained in:
2026-07-28 10:17:35 +01:00
parent 7a236de017
commit ebebd5d4a5
6 changed files with 166 additions and 11 deletions
+32
View File
@@ -0,0 +1,32 @@
# restic actions registry
from playbook.action_registry import ActionRegistry
from playbook.models import StepLog
import sys
import json
import docker
import subprocess
from typing import List, Dict, Any, Tuple
dbpgactions = ActionRegistry("dbpg_actions_reg")
@dbpgactions.register(name="dump_pg_database", version="")
def dump_pg_database(ctx, name) -> StepLog:
return StepLog.ok(name, "")
# NOTE: this functions ought to be in their own registry, but I need inter
# registry communication to be possible first
###############################################################################
##### DOCKER FUNCTIONS ########################################################
@dbpgactions.register(name="get_service_container", version="")
def get_service_container(ctx, name) -> StepLog:
client = docker.from_env()
filters: Dict[str, Any]= {"label": [f"com.docker.compose.service=gitea-db"]}
print(client.containers.list(filters=filters, all=True), file=sys.stderr)
return StepLog.ok(name, "cool beans")
+7
View File
@@ -174,3 +174,10 @@ def backup_data_to_restic_repo(ctx, name) -> StepLog:
}
return StepLog.ok(name, str(msg))
#-- BIG NOTE ------------------------------------------------------------------#
# I will use the restic registry for database actions until I make it so cross #
# registry calls with context are possible. But right now the yaml config #
# doesnt support that anyway. #
#------------------------------------------------------------------------------#