docs: centralize and rationalize apt-ostree.py documentation; overhaul configuration management with robust env var mapping and validation

This commit is contained in:
Joe Particle 2025-07-16 16:35:51 +00:00
parent 20db68a97f
commit 6883cadf4d
13 changed files with 1770 additions and 36 deletions

72
debug_config.py Normal file
View file

@ -0,0 +1,72 @@
#!/usr/bin/env python3
"""
Debug script for configuration environment variable handling
"""
import os
import sys
from pathlib import Path
# Add the apt-ostree module to path
sys.path.insert(0, str(Path(__file__).parent / "src/apt-ostree.py/python"))
from utils.config import ConfigManager
def debug_environment_variables():
"""Debug environment variable handling"""
print("=== Debug Environment Variables ===\n")
# Set test environment variables
os.environ['APT_OSTREE_DAEMON__LOGGING__LEVEL'] = 'DEBUG'
os.environ['APT_OSTREE_DAEMON__CONCURRENCY__MAX_WORKERS'] = '8'
os.environ['APT_OSTREE_DAEMON__LOGGING__COMPRESSION'] = 'false'
os.environ['APT_OSTREE_PERFORMANCE__CACHE_TTL'] = '7200'
print("Environment variables set:")
for key, value in os.environ.items():
if key.startswith('APT_OSTREE_'):
print(f" {key} = {value}")
# Create config manager
config_manager = ConfigManager("/tmp/debug-config.yaml")
print(f"\nConfig manager env_prefix: {config_manager.env_prefix}")
# Load config
config = config_manager.load_config()
if config:
print("\nConfiguration loaded successfully")
print(f"Log level: {config_manager.get('daemon.logging.level')}")
print(f"Max workers: {config_manager.get('daemon.concurrency.max_workers')}")
print(f"Compression: {config_manager.get('daemon.logging.compression')}")
print(f"Cache TTL: {config_manager.get('performance.cache_ttl')}")
# Check if environment variables were applied
expected_values = {
'daemon.logging.level': 'DEBUG',
'daemon.concurrency.max_workers': 8,
'daemon.logging.compression': False,
'performance.cache_ttl': 7200
}
print("\nChecking expected values:")
for key, expected in expected_values.items():
actual = config_manager.get(key)
status = "" if actual == expected else ""
print(f" {status} {key}: expected {expected}, got {actual}")
else:
print("❌ Failed to load configuration")
# Clean up
for key in [
'APT_OSTREE_DAEMON__LOGGING__LEVEL',
'APT_OSTREE_DAEMON__CONCURRENCY__MAX_WORKERS',
'APT_OSTREE_DAEMON__LOGGING__COMPRESSION',
'APT_OSTREE_PERFORMANCE__CACHE_TTL']:
if key in os.environ:
del os.environ[key]
if __name__ == "__main__":
debug_environment_variables()