Files
Unraid-AppOps-Gateway-Public/backend/app/services/preflight_service.py
T

31 lines
1.0 KiB
Python

from __future__ import annotations
NO_ROLLBACK_ACTIONS = {
'container.clear_logs',
'container.stop',
'gateway.clear_cache',
'unraid.mover.start',
'volume.delete',
}
def build_preflight(action: str, target: str, policy_decision: str, risk: str):
dependencies = ['connector']
if action.startswith('container.'):
dependencies.append('container runtime')
if action.startswith('sonarr.') or action.startswith('radarr.'):
dependencies.append('media indexer api')
return {
'action': action,
'target': target,
'risk': risk,
'policyDecision': policy_decision,
'affectedApps': [target],
'dependencies': dependencies,
'preChecks': ['policy evaluate', 'connector config', 'maintenance status'],
'postChecks': ['connector state', 'service availability', 'policy audit'],
'rollbackAvailable': action not in NO_ROLLBACK_ACTIONS,
'auditPreview': f'Action {action} on {target} is prepared for execution review.',
}