mirror of
https://github.com/element-hq/ess-helm.git
synced 2026-11-24 02:51:28 -08:00
Merge pull request #1353 from element-hq/gaelg/pretty_logger_rich
Refactor logging to generate the summary in a log file
This commit is contained in:
21 files changed
+552
-457
No files matched your search
@@ -0,0 +1 @@
|
||||
Log all migration process to a summary log file.
|
||||
@@ -9,18 +9,17 @@ Main CLI entry point for the migration script.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
|
||||
from rich.logging import RichHandler
|
||||
|
||||
from .element_web import ELEMENT_WEB_STRATEGY_NAME
|
||||
from .engine import MigrationEngine
|
||||
from .hookshot import HOOKSHOT_STRATEGY_NAME
|
||||
from .inputs import InputProcessor, ValidationError
|
||||
from .mas import MAS_STRATEGY_NAME, parse_postgres_uri
|
||||
from .outputs import generate_helm_values, write_outputs
|
||||
from .rich_output import ProgressReporter, log_command, print_section, print_separator, print_table
|
||||
from .models import GlobalOptions
|
||||
from .outputs import create_output_dir, generate_helm_values, write_outputs
|
||||
from .rich_output import ProgressReporter, log_command, print_prompt, print_section, print_separator, print_table
|
||||
from .synapse import SYNAPSE_STRATEGY_NAME
|
||||
from .utils import press_enter_to_continue, prompt_for_database_choice
|
||||
|
||||
@@ -157,31 +156,23 @@ Examples:
|
||||
else:
|
||||
logger.setLevel(logging.CRITICAL)
|
||||
|
||||
pretty_logger = logging.getLogger("migration:summary")
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.CRITICAL if args.quiet else logging.INFO)
|
||||
pretty_sh = logging.StreamHandler()
|
||||
# Use rich for colored output if available and not running in a test environment
|
||||
# RichHandler doesn't work well with pytest's capsys, so we detect pytest via PYTEST_CURRENT_TEST env var
|
||||
# Similar logic to press_enter_to_continue function in utils.py
|
||||
is_pytest = bool(os.environ.get("PYTEST_CURRENT_TEST"))
|
||||
if not is_pytest:
|
||||
pretty_handler = RichHandler(
|
||||
rich_tracebacks=False,
|
||||
show_time=False,
|
||||
show_level=False,
|
||||
show_path=False,
|
||||
enable_link_path=False,
|
||||
# Validate and create output directory
|
||||
create_output_dir(args.output_dir)
|
||||
|
||||
summary_fh = logging.FileHandler(
|
||||
f"{args.output_dir}/migration-summary-{datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log"
|
||||
)
|
||||
summary_fh.setFormatter(
|
||||
logging.Formatter(
|
||||
"%(asctime)s - %(levelname)s - %(message)s",
|
||||
)
|
||||
pretty_logger.addHandler(pretty_handler)
|
||||
else:
|
||||
# Use basic formatter for pytest compatibility
|
||||
pretty_sh.setFormatter(
|
||||
logging.Formatter(
|
||||
"%(message)s",
|
||||
)
|
||||
)
|
||||
pretty_logger.addHandler(pretty_sh)
|
||||
)
|
||||
|
||||
summary_logger = logging.getLogger("migration:summary")
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
summary_logger.addHandler(summary_fh)
|
||||
logger.addHandler(summary_fh)
|
||||
|
||||
# Set up progress reporter
|
||||
steps = [
|
||||
@@ -190,10 +181,11 @@ Examples:
|
||||
GENERATING_VALUES_STEP,
|
||||
WRITING_OUTPUTS_STEP,
|
||||
]
|
||||
global_options = GlobalOptions(
|
||||
quiet_mode=args.quiet,
|
||||
)
|
||||
reporter = ProgressReporter(
|
||||
pretty_logger=pretty_logger,
|
||||
steps=steps,
|
||||
verbose=args.verbose,
|
||||
summary_logger=summary_logger, steps=steps, verbose=args.verbose, global_options=global_options
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -235,7 +227,9 @@ Examples:
|
||||
|
||||
# Run migration
|
||||
reporter.report_step(MIGRATING_STEP)
|
||||
engine = MigrationEngine(input_processor=input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(
|
||||
input_processor=input_processor, summary_logger=summary_logger, global_options=global_options
|
||||
)
|
||||
|
||||
# Set database mode if provided via command line
|
||||
if args.database_mode:
|
||||
@@ -245,7 +239,9 @@ Examples:
|
||||
engine.global_options.use_existing_database = False
|
||||
else:
|
||||
# Prompt for database choice only if not already set via command line
|
||||
engine.global_options.use_existing_database = prompt_for_database_choice(pretty_logger)
|
||||
engine.global_options.use_existing_database = prompt_for_database_choice(
|
||||
summary_logger, global_options=engine.global_options
|
||||
)
|
||||
|
||||
ess_values = engine.run_migration()
|
||||
|
||||
@@ -266,8 +262,8 @@ Examples:
|
||||
all_file_paths = [values_path] + secret_paths + configmap_paths
|
||||
|
||||
# Display migration summary
|
||||
press_enter_to_continue(pretty_logger)
|
||||
print_section("📊 MIGRATION SUMMARY", logger=pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
print_section("📊 MIGRATION SUMMARY", logger=summary_logger)
|
||||
|
||||
# Create a comprehensive mapping of source config paths to target ESS paths
|
||||
migration_mapping = {}
|
||||
@@ -297,9 +293,9 @@ Examples:
|
||||
table_data,
|
||||
headers=["Source", "Path", "ESS Value"],
|
||||
title="✅ ESS COMMUNITY VALUES CREATED SUCCESSFULLY",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
if engine.ess_config["synapse"].get("workers"):
|
||||
# Prepare table data for workers
|
||||
@@ -310,14 +306,20 @@ Examples:
|
||||
worker_data,
|
||||
headers=["Worker", "Replicas"],
|
||||
title="📝 SYNAPSE WORKERS",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
# ask user to take a second look
|
||||
pretty_logger.info(" ⚠️ Please review the workers in your values files before proceeding.\n")
|
||||
press_enter_to_continue(pretty_logger)
|
||||
print_prompt(
|
||||
" ⚠️ Please review the workers in your values files before proceeding.\n",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
else:
|
||||
pretty_logger.info(" ✅ No workers found, using a single main Synapse process")
|
||||
press_enter_to_continue(pretty_logger)
|
||||
print_prompt(
|
||||
" ✅ No workers found, using a single main Synapse process", style="default", logger=summary_logger
|
||||
)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
if engine.discovered_secrets:
|
||||
# Prepare table data for secrets
|
||||
secret_data = []
|
||||
@@ -333,9 +335,9 @@ Examples:
|
||||
secret_data,
|
||||
headers=["Source File", "Config Key", "Secret Path in Values"],
|
||||
title="🔐 MIGRATED SECRETS",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
if engine.init_by_ess_secrets:
|
||||
# Prepare table data for auto-generated secrets
|
||||
@@ -344,12 +346,12 @@ Examples:
|
||||
init_secret_data,
|
||||
headers=["Secret Path in Values"],
|
||||
title="⚠️ ESS-INITIALIZED SECRETS",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
pretty_logger.info(
|
||||
summary_logger.info(
|
||||
"These secrets are not required for migration but will be created automatically during deployment."
|
||||
)
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
# Show override warnings within the migration summary
|
||||
if engine.override_warnings:
|
||||
@@ -359,21 +361,21 @@ Examples:
|
||||
override_data,
|
||||
headers=["Warning"],
|
||||
title="⚠️ ESS-MANAGED COMPONENTS CONFIGURATIONS DETECTED",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
pretty_logger.info(
|
||||
summary_logger.info(
|
||||
" These components settings are managed by ESS Community and"
|
||||
" your settings may be overriden if they are not configurable in ESS"
|
||||
)
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
print_section(
|
||||
"❗ ACTION REQUIRED:\n "
|
||||
"Double-check and maybe remove these settings from your additional configuration to avoid conflicts.",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
# Show underride warnings within the migration summary
|
||||
if engine.underride_warnings:
|
||||
@@ -383,53 +385,63 @@ Examples:
|
||||
underride_data,
|
||||
headers=["Warning"],
|
||||
title="ℹ️ DEVIATION FROM ESS COMMUNITY DEFAULT CONFIGURATIONS FOUND",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
pretty_logger.info(" These settings have ESS defaults that your values will override")
|
||||
press_enter_to_continue(pretty_logger)
|
||||
print_prompt(
|
||||
" These settings have ESS defaults that your values will override",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
# Show clean migration message
|
||||
if not engine.override_warnings and not engine.underride_warnings:
|
||||
press_enter_to_continue(pretty_logger)
|
||||
print_section("🎉 CLEAN MIGRATION: No unexpected overrides detected!", logger=pretty_logger)
|
||||
pretty_logger.info(" All configurations have been properly migrated to ESS.")
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
print_section("🎉 CLEAN MIGRATION: No unexpected overrides detected!", logger=summary_logger)
|
||||
print_prompt(
|
||||
" All configurations have been properly migrated to ESS.", style="default", logger=summary_logger
|
||||
)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
# Show next steps for deployment
|
||||
print_section("🚀 NEXT STEPS TO DEPLOY ELEMENT SERVER SUITE:", logger=pretty_logger)
|
||||
press_enter_to_continue(pretty_logger)
|
||||
print_section("🚀 NEXT STEPS TO DEPLOY ELEMENT SERVER SUITE:", logger=summary_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
# Use incremental step numbering
|
||||
step_number = 1
|
||||
|
||||
pretty_logger.info(f"{step_number}. Create Kubernetes namespace:")
|
||||
print_prompt(f"{step_number}. Create Kubernetes namespace:", style="default", logger=summary_logger)
|
||||
step_number += 1
|
||||
log_command("kubectl create namespace ess", logger=pretty_logger)
|
||||
log_command("kubectl create namespace ess", logger=summary_logger)
|
||||
|
||||
# Check if there are configmaps or secrets to apply
|
||||
has_configmaps = len(configmap_paths) > 0
|
||||
has_secrets = len(secret_paths) > 0
|
||||
|
||||
if has_configmaps or has_secrets:
|
||||
pretty_logger.info(f"{step_number}. Apply generated Kubernetes resources:")
|
||||
print_prompt(
|
||||
f"{step_number}. Apply generated Kubernetes resources:", style="default", logger=summary_logger
|
||||
)
|
||||
step_number += 1
|
||||
if has_configmaps:
|
||||
for configmap_path in configmap_paths:
|
||||
log_command(f"kubectl apply -f {configmap_path} -n ess", logger=pretty_logger)
|
||||
log_command(f"kubectl apply -f {configmap_path} -n ess", logger=summary_logger)
|
||||
if has_secrets:
|
||||
for secret_path in secret_paths:
|
||||
log_command(f"kubectl apply -f {secret_path} -n ess", logger=pretty_logger)
|
||||
pretty_logger.info("")
|
||||
log_command(f"kubectl apply -f {secret_path} -n ess", logger=summary_logger)
|
||||
print_prompt("", style="default", logger=summary_logger)
|
||||
|
||||
pretty_logger.info(f"{step_number}.Install ESS using Helm with the generated values:")
|
||||
print_prompt(
|
||||
f"{step_number}.Install ESS using Helm with the generated values:", style="default", logger=summary_logger
|
||||
)
|
||||
step_number += 1
|
||||
log_command(
|
||||
f'helm upgrade --install --namespace "ess" ess '
|
||||
f"oci://ghcr.io/element-hq/ess-helm/matrix-stack -f {values_path} --wait",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
# Get the original media path from Synapse configuration
|
||||
synapse_input = engine.input_processor.input_for_strategy(SYNAPSE_STRATEGY_NAME)
|
||||
@@ -438,22 +450,34 @@ Examples:
|
||||
original_media_path = synapse_input.config["media_store_path"]
|
||||
|
||||
if original_media_path:
|
||||
pretty_logger.info(f"{step_number}. Copy media from your existing setup to ESS persistent volume:")
|
||||
print_prompt(
|
||||
f"{step_number}. Copy media from your existing setup to ESS persistent volume:",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
log_command(
|
||||
f"kubectl cp {original_media_path} ess-synapse-0:/media/media_store -n ess",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
pretty_logger.info("📚 For more details on deployment and data migration, refer to the ESS documentation.")
|
||||
press_enter_to_continue(pretty_logger)
|
||||
print_prompt(
|
||||
"📚 For more details on deployment and data migration, refer to the ESS documentation.",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
# Add database-specific instructions
|
||||
if not engine.global_options.use_existing_database:
|
||||
print_section("📋 DATABASE IMPORT INSTRUCTIONS", logger=pretty_logger)
|
||||
pretty_logger.info("Since you chose to use ESS-managed PostgreSQL, you'll need to import your")
|
||||
pretty_logger.info("existing database schema after deployment. Here are the steps:")
|
||||
press_enter_to_continue(pretty_logger)
|
||||
print_section("📋 DATABASE IMPORT INSTRUCTIONS", logger=summary_logger)
|
||||
print_prompt(
|
||||
"Since you chose to use ESS-managed PostgreSQL, you'll need to import your"
|
||||
"existing database schema after deployment. Here are the steps:",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
# Get source database configuration from input files
|
||||
synapse_input = engine.input_processor.input_for_strategy(SYNAPSE_STRATEGY_NAME)
|
||||
@@ -482,32 +506,40 @@ Examples:
|
||||
|
||||
# Step 1: Stop workloads before importing
|
||||
step_number = 1
|
||||
pretty_logger.info(f"{step_number}. Stop Synapse and MAS workloads before importing:")
|
||||
print_prompt(
|
||||
f"{step_number}. Stop Synapse and MAS workloads before importing:",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
log_command(
|
||||
'kubectl scale sts -l "app.kubernetes.io/component=matrix-server" -n ess --replicas=0',
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
if mas_input:
|
||||
log_command(
|
||||
'kubectl scale deploy -l "app.kubernetes.io/component=matrix-authentication" -n ess --replicas=0',
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
step_number += 1
|
||||
|
||||
# Step 2: Create database dumps
|
||||
pretty_logger.info(f"{step_number}. After ESS is deployed, create database dumps for Synapse:")
|
||||
print_prompt(
|
||||
f"{step_number}. After ESS is deployed, create database dumps for Synapse:",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
log_command(
|
||||
f"pg_dump -C -U {source_synapse_user} -d {source_synapse_db} > synapse.sql",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
# Only show MAS dump instructions if MAS is being migrated
|
||||
if mas_input:
|
||||
log_command(f"pg_dump -C -U {source_mas_user} -d {source_mas_db} > mas.sql", logger=pretty_logger)
|
||||
log_command(f"pg_dump -C -U {source_mas_user} -d {source_mas_db} > mas.sql", logger=summary_logger)
|
||||
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
step_number += 1
|
||||
|
||||
# Step 3: Transform the dumps (only show if transformations are needed)
|
||||
@@ -517,57 +549,71 @@ Examples:
|
||||
mas_needs_transform = mas_input and (source_mas_db != target_mas_db or source_mas_user != target_mas_user)
|
||||
|
||||
if synapse_needs_transform or mas_needs_transform:
|
||||
pretty_logger.info(f"{step_number}. Transform the dumps to match ESS database names and owners:")
|
||||
print_prompt(
|
||||
f"{step_number}. Transform the dumps to match ESS database names and owners:",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
# Only show database name transformation if source and target are different
|
||||
if source_synapse_db != target_synapse_db:
|
||||
pretty_logger.info(" # Replace source database names with ESS database names")
|
||||
print_prompt(
|
||||
" # Replace source database names with ESS database names",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
log_command(
|
||||
f"sed -i 's/DATABASE {source_synapse_db}/DATABASE {target_synapse_db}/' synapse.sql",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
# Only show MAS database transformation if MAS is being migrated and names are different
|
||||
if mas_input and source_mas_db != target_mas_db:
|
||||
log_command(
|
||||
f"sed -i 's/DATABASE {source_mas_db}/DATABASE {target_mas_db}/' mas.sql",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
# Only show owner transformation if source and target are different
|
||||
if source_synapse_user != target_synapse_user:
|
||||
pretty_logger.info(" # Replace source owners with ESS owners")
|
||||
print_prompt(" # Replace source owners with ESS owners", style="default", logger=summary_logger)
|
||||
log_command(
|
||||
f"sed -i 's/OWNER TO.*{source_synapse_user}/OWNER TO {target_synapse_user}/' synapse.sql",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
# Only show MAS owner transformation if MAS is being migrated and owners are different
|
||||
if mas_input and source_mas_user != target_mas_user:
|
||||
log_command(
|
||||
f"sed -i 's/OWNER TO.*{source_mas_user}/OWNER TO {target_mas_user}/' mas.sql",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
step_number += 1
|
||||
|
||||
# Step: Copy the dumps
|
||||
pretty_logger.info(f"{step_number}. Copy the dumps to the ESS PostgreSQL pod:")
|
||||
log_command("kubectl cp synapse.sql ess-postgres-0:/tmp -n ess", logger=pretty_logger)
|
||||
print_prompt(
|
||||
f"{step_number}. Copy the dumps to the ESS PostgreSQL pod:", style="default", logger=summary_logger
|
||||
)
|
||||
log_command("kubectl cp synapse.sql ess-postgres-0:/tmp -n ess", logger=summary_logger)
|
||||
|
||||
# Only show MAS copy instructions if MAS is being migrated
|
||||
if mas_input:
|
||||
log_command("kubectl cp mas.sql ess-postgres-0:/tmp -n ess", logger=pretty_logger)
|
||||
log_command("kubectl cp mas.sql ess-postgres-0:/tmp -n ess", logger=summary_logger)
|
||||
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
step_number += 1
|
||||
|
||||
# Step: Import the dumps
|
||||
pretty_logger.info(f"{step_number}. Import the dumps into the ESS-managed PostgreSQL:")
|
||||
print_prompt(
|
||||
f"{step_number}. Import the dumps into the ESS-managed PostgreSQL:",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
log_command(
|
||||
'kubectl exec -n ess sts/ess-postgres -- bash -c "psql -U postgres -d synapse < /tmp/synapse.sql"',
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
# Only show MAS import instructions if MAS is being migrated
|
||||
@@ -575,29 +621,33 @@ Examples:
|
||||
log_command(
|
||||
'kubectl exec -n ess sts/ess-postgres -- bash -c "psql -U postgres -d '
|
||||
'matrixauthenticationservice < /tmp/mas.sql"',
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
pretty_logger.info("")
|
||||
print_prompt("", style="default", logger=summary_logger)
|
||||
step_number += 1
|
||||
|
||||
# Step: Restart workloads
|
||||
pretty_logger.info(f"{step_number}. Restart Synapse and MAS to use the imported data:")
|
||||
print_prompt(
|
||||
f"{step_number}. Restart Synapse and MAS to use the imported data:",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
log_command(
|
||||
'kubectl scale sts -l "app.kubernetes.io/component=matrix-server" -n ess --replicas=1',
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
# Only show MAS restart instructions if MAS is being migrated
|
||||
if mas_input:
|
||||
log_command(
|
||||
'kubectl scale deploy -l "app.kubernetes.io/component=matrix-authentication" -n ess --replicas=1',
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
press_enter_to_continue(pretty_logger)
|
||||
press_enter_to_continue(summary_logger, engine.global_options)
|
||||
|
||||
print_separator(logger=pretty_logger)
|
||||
print_separator(logger=summary_logger)
|
||||
|
||||
reporter.report_success(args.output_dir, all_file_paths)
|
||||
logging.info("Migration completed successfully!")
|
||||
|
||||
@@ -10,15 +10,16 @@ Conflict resolution utilities for migration.
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from .models import DiscoveredSecretTracking, SecretSource, ValueSourceTracking
|
||||
from .rich_output import print_separator
|
||||
from .utils import is_quiet_mode, prompt_choice, prompt_value, set_nested_value
|
||||
from .models import DiscoveredSecretTracking, GlobalOptions, SecretSource, ValueSourceTracking
|
||||
from .rich_output import print_prompt, print_separator
|
||||
from .utils import prompt_choice, prompt_value, set_nested_value
|
||||
|
||||
|
||||
def prompt_for_conflict_resolution(
|
||||
pretty_logger: logging.Logger,
|
||||
summary_logger: logging.Logger,
|
||||
conflict_key: str,
|
||||
value_to_strategies: dict[str, list[str]],
|
||||
global_options: GlobalOptions,
|
||||
display_value_max_length: int = 50,
|
||||
enable_custom: bool = False,
|
||||
) -> tuple[str | None, bool]:
|
||||
@@ -26,7 +27,7 @@ def prompt_for_conflict_resolution(
|
||||
Prompt user to resolve a conflict.
|
||||
|
||||
Args:
|
||||
pretty_logger: Logger for displaying prompts
|
||||
summary_logger: Logger for displaying prompts
|
||||
conflict_key: The key/path being resolved (for display)
|
||||
value_to_strategies: Mapping of value strings to list of strategy names
|
||||
display_value_max_length: Max length for value display before truncation
|
||||
@@ -40,16 +41,19 @@ def prompt_for_conflict_resolution(
|
||||
if enable_custom:
|
||||
options.append("Enter custom value")
|
||||
|
||||
choice = prompt_choice(pretty_logger, f"Select value for '{conflict_key}':", options)
|
||||
choice = prompt_choice(
|
||||
summary_logger, f"Select value for '{conflict_key}':", options, global_options=global_options
|
||||
)
|
||||
is_custom = choice == "Enter custom value"
|
||||
selected_value = choice if not is_custom else None
|
||||
return selected_value, is_custom
|
||||
|
||||
|
||||
def resolve_value_conflicts(
|
||||
pretty_logger: logging.Logger,
|
||||
summary_logger: logging.Logger,
|
||||
value_source_tracking: ValueSourceTracking,
|
||||
ess_config: dict[str, Any],
|
||||
global_options: GlobalOptions,
|
||||
) -> None:
|
||||
"""Resolve conflicts where multiple strategies provide different values for same ESS path."""
|
||||
conflicts = value_source_tracking.get_conflicts()
|
||||
@@ -64,7 +68,7 @@ def resolve_value_conflicts(
|
||||
logging.debug(f"Consistent values for {ess_path}: {first_value}")
|
||||
continue
|
||||
|
||||
if is_quiet_mode(pretty_logger):
|
||||
if global_options.quiet_mode:
|
||||
logging.info(f"Conflict detected for {ess_path}, using first value: {first_value}")
|
||||
continue
|
||||
|
||||
@@ -74,25 +78,28 @@ def resolve_value_conflicts(
|
||||
value_str = str(source.value)
|
||||
value_to_strategies.setdefault(value_str, []).append(source.strategy_name)
|
||||
|
||||
pretty_logger.info(f"\n⚠️ CONFLICT for '{ess_path}'")
|
||||
pretty_logger.info(" Multiple configurations provide different values:")
|
||||
print_prompt(f"⚠️ CONFLICT for '{ess_path}'", style="default", logger=summary_logger)
|
||||
print_prompt(" Multiple configurations provide different values:", style="default", logger=summary_logger)
|
||||
for source in sources:
|
||||
pretty_logger.info(f" • {source.strategy_name} ({source.source_path}): {source.value}")
|
||||
print_prompt(
|
||||
f" • {source.strategy_name} ({source.source_path}): {source.value}",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
selected_value, is_custom = prompt_for_conflict_resolution(
|
||||
pretty_logger, ess_path, value_to_strategies, enable_custom=True
|
||||
summary_logger, ess_path, value_to_strategies, enable_custom=True, global_options=global_options
|
||||
)
|
||||
|
||||
if is_custom:
|
||||
selected_value = prompt_value(pretty_logger, "Enter custom value:")
|
||||
selected_value = prompt_value(summary_logger, "Enter custom value:", global_options)
|
||||
|
||||
set_nested_value(ess_config, ess_path, selected_value)
|
||||
logging.info(f"Resolved {ess_path} = {selected_value}")
|
||||
|
||||
|
||||
def resolve_secret_conflicts(
|
||||
pretty_logger: logging.Logger,
|
||||
secret_tracking: DiscoveredSecretTracking,
|
||||
summary_logger: logging.Logger, secret_tracking: DiscoveredSecretTracking, global_options: GlobalOptions
|
||||
) -> None:
|
||||
"""Resolve conflicts where multiple strategies discovered different values for the same secret."""
|
||||
conflicts = secret_tracking.get_conflicts()
|
||||
@@ -101,15 +108,19 @@ def resolve_secret_conflicts(
|
||||
|
||||
logger = logging.getLogger("migration")
|
||||
|
||||
pretty_logger.info("")
|
||||
print_separator(logger=pretty_logger)
|
||||
pretty_logger.info("🔐 RESOLVING SECRET CONFLICTS")
|
||||
print_separator(logger=pretty_logger)
|
||||
pretty_logger.info("Some secrets were discovered by multiple strategies with different values.")
|
||||
pretty_logger.info("Please select which value to use for each:")
|
||||
pretty_logger.info("")
|
||||
print_prompt("", style="default", logger=summary_logger)
|
||||
print_separator(logger=summary_logger)
|
||||
print_prompt("🔐 RESOLVING SECRET CONFLICTS", style="default", logger=summary_logger)
|
||||
print_separator(logger=summary_logger)
|
||||
print_prompt(
|
||||
"Some secrets were discovered by multiple strategies with different values.",
|
||||
style="default",
|
||||
logger=summary_logger,
|
||||
)
|
||||
print_prompt("Please select which value to use for each:", style="default", logger=summary_logger)
|
||||
print_prompt("", style="default", logger=summary_logger)
|
||||
|
||||
if is_quiet_mode(pretty_logger):
|
||||
if global_options.quiet_mode:
|
||||
for secret_key, sources in sorted(conflicts.items()):
|
||||
logger.info("Conflict for %s: using first value (from %s)", secret_key, sources[0].strategy_name)
|
||||
secret_tracking.sources[secret_key] = [sources[0]]
|
||||
@@ -121,16 +132,22 @@ def resolve_secret_conflicts(
|
||||
for source in sources:
|
||||
value_to_strategies.setdefault(source.value, []).append(source.strategy_name)
|
||||
|
||||
pretty_logger.info("⚠️ Conflict for secret: %s", secret_key)
|
||||
pretty_logger.info(" Discovered by multiple strategies with different values:")
|
||||
print_prompt(f"⚠️ Conflict for secret: {secret_key}", style="default", logger=summary_logger)
|
||||
print_prompt(
|
||||
" Discovered by multiple strategies with different values:", style="default", logger=summary_logger
|
||||
)
|
||||
for value, strategies in sorted(value_to_strategies.items()):
|
||||
display_value = value if len(value) <= 50 else f"{value[:47]}..."
|
||||
pretty_logger.info(f" • {display_value} (from: {', '.join(strategies)})")
|
||||
print_prompt(
|
||||
f" • {display_value} (from: {', '.join(strategies)})", style="default", logger=summary_logger
|
||||
)
|
||||
|
||||
selected_value, is_custom = prompt_for_conflict_resolution(pretty_logger, secret_key, value_to_strategies)
|
||||
selected_value, is_custom = prompt_for_conflict_resolution(
|
||||
summary_logger, secret_key, value_to_strategies, global_options
|
||||
)
|
||||
|
||||
if is_custom:
|
||||
new_value = prompt_value(pretty_logger, "Enter custom value:")
|
||||
new_value = prompt_value(summary_logger, "Enter custom value:", global_options)
|
||||
secret_tracking.sources[secret_key] = [
|
||||
SecretSource(
|
||||
strategy_name="user-provided",
|
||||
@@ -142,7 +159,7 @@ def resolve_secret_conflicts(
|
||||
else:
|
||||
secret_tracking.sources[secret_key] = [s for s in sources if s.value == selected_value]
|
||||
|
||||
pretty_logger.info(f" ✅ Resolved {secret_key}")
|
||||
pretty_logger.info("")
|
||||
print_prompt(f" ✅ Resolved {secret_key}", style="default", logger=summary_logger)
|
||||
print_prompt("", style="default", logger=summary_logger)
|
||||
|
||||
print_separator(logger=pretty_logger)
|
||||
print_separator(logger=summary_logger)
|
||||
@@ -30,7 +30,8 @@ class MigrationEngine:
|
||||
"""Core migration engine that handles the conversion process."""
|
||||
|
||||
input_processor: InputProcessor = field(init=True)
|
||||
pretty_logger: logging.Logger = field(init=True)
|
||||
summary_logger: logging.Logger = field(init=True)
|
||||
global_options: GlobalOptions = field(init=True)
|
||||
ess_config: dict[str, Any] = field(default_factory=dict)
|
||||
secrets: list[Secret] = field(default_factory=list)
|
||||
configmaps: list[ConfigMap] = field(default_factory=list)
|
||||
@@ -39,7 +40,6 @@ class MigrationEngine:
|
||||
discovered_secrets: list[DiscoveredSecret] = field(default_factory=list)
|
||||
init_by_ess_secrets: list[str] = field(default_factory=list)
|
||||
migrators: list[MigrationService] = field(default_factory=list)
|
||||
global_options: GlobalOptions = field(default_factory=GlobalOptions)
|
||||
value_source_tracking: ValueSourceTracking = field(default_factory=ValueSourceTracking)
|
||||
secret_tracking: DiscoveredSecretTracking = field(default_factory=DiscoveredSecretTracking)
|
||||
|
||||
@@ -98,7 +98,7 @@ class MigrationEngine:
|
||||
self.migrators.append(
|
||||
MigrationService(
|
||||
input=migration_input,
|
||||
pretty_logger=self.pretty_logger,
|
||||
summary_logger=self.summary_logger,
|
||||
ess_config=self.ess_config,
|
||||
migration=migration,
|
||||
extra_files_strategy=extra_file_strategy,
|
||||
@@ -145,10 +145,10 @@ class MigrationEngine:
|
||||
migrator.handle_secrets_phase()
|
||||
|
||||
# Resolve secret conflicts after all migrations
|
||||
resolve_secret_conflicts(self.pretty_logger, self.secret_tracking)
|
||||
resolve_secret_conflicts(self.summary_logger, self.secret_tracking, self.global_options)
|
||||
|
||||
# Resolve value conflicts after all migrations
|
||||
resolve_value_conflicts(self.pretty_logger, self.value_source_tracking, self.ess_config)
|
||||
resolve_value_conflicts(self.summary_logger, self.value_source_tracking, self.ess_config, self.global_options)
|
||||
|
||||
# Disable any ESS component that was not migrated (absent from config)
|
||||
ALL_ESS_COMPONENTS = {
|
||||
|
||||
@@ -14,9 +14,9 @@ from pathlib import Path
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from .interfaces import ExtraFilesDiscoveryStrategy, SecretDiscoveryStrategy
|
||||
from .models import DiscoverableSecret, DiscoveredExtraFile, DiscoveredPath
|
||||
from .rich_output import print_section, print_separator
|
||||
from .utils import is_quiet_mode, prompt_choice, prompt_value, prompt_yes_no
|
||||
from .models import DiscoverableSecret, DiscoveredExtraFile, DiscoveredPath, GlobalOptions
|
||||
from .rich_output import print_prompt, print_section, print_separator
|
||||
from .utils import prompt_choice, prompt_value, prompt_yes_no
|
||||
|
||||
logger = logging.getLogger("migration")
|
||||
|
||||
@@ -39,12 +39,13 @@ def ess_schema_config_key_secret_paths(ess_schema: dict[str, DiscoverableSecret]
|
||||
class ExtraFilesDiscovery:
|
||||
"""Handles discovery and extraction of extra files from configuration files."""
|
||||
|
||||
pretty_logger: logging.Logger = field(init=True)
|
||||
summary_logger: logging.Logger = field(init=True)
|
||||
strategy: ExtraFilesDiscoveryStrategy = field(init=True) # Strategy for component-specific secret discovery
|
||||
secrets_strategy: SecretDiscoveryStrategy | None = field(
|
||||
init=True
|
||||
) # Strategy for component-specific secret discovery
|
||||
source_file: str = field(init=True) # Source file path
|
||||
global_options: GlobalOptions = field(init=True) # Global options for the migration script
|
||||
discovered_extra_files: dict[Path, DiscoveredExtraFile] = field(
|
||||
default_factory=dict
|
||||
) # Discovered Extra File to mount in ESS
|
||||
@@ -177,16 +178,20 @@ class ExtraFilesDiscovery:
|
||||
if _discovered_path.source_path.is_dir():
|
||||
files_in_dir = self._handle_directory(_discovered_path)
|
||||
logger.info(f"Found {len(files_in_dir)} files in directory {_discovered_path.source_path}")
|
||||
self.pretty_logger.info(
|
||||
self.summary_logger.info(
|
||||
f"📁 Found {len(files_in_dir)} files in directory: {_discovered_path.source_path}"
|
||||
)
|
||||
# Show the files being imported
|
||||
for file_path in files_in_dir:
|
||||
logger.info(f" - {file_path}")
|
||||
self.pretty_logger.info(f" 📄 {Path(file_path).name}")
|
||||
print_prompt(f" 📄 {Path(file_path).name}", style="default", logger=self.summary_logger)
|
||||
if not files_in_dir:
|
||||
logger.warning(f"No files found in directory: {_discovered_path.source_path}")
|
||||
self.pretty_logger.info(f"⚠️ No files found in directory: {_discovered_path.source_path}")
|
||||
print_prompt(
|
||||
f"⚠️ No files found in directory: {_discovered_path.source_path}",
|
||||
style="default",
|
||||
logger=self.summary_logger,
|
||||
)
|
||||
else:
|
||||
if _discovered_path.source_path not in self.discovered_extra_files:
|
||||
try:
|
||||
@@ -234,7 +239,7 @@ class ExtraFilesDiscovery:
|
||||
Prompt user for alternative paths when files are missing.
|
||||
"""
|
||||
# Check if quiet mode is enabled
|
||||
if is_quiet_mode(self.pretty_logger) and self.missing_file_paths:
|
||||
if self.global_options.quiet_mode and self.missing_file_paths:
|
||||
missing_files = [str(fp.source_path) for fp in self.missing_file_paths]
|
||||
raise ExtraFilesError(
|
||||
f"Missing extra files in quiet mode: {', '.join(missing_files)}. "
|
||||
@@ -246,26 +251,35 @@ class ExtraFilesDiscovery:
|
||||
return
|
||||
|
||||
component_name = self.strategy.component_name
|
||||
print_section(f"📁 EXTRA FILES DISCOVERY ({component_name})", logger=self.pretty_logger)
|
||||
self.pretty_logger.info("The following extra files were referenced in your configuration")
|
||||
self.pretty_logger.info("but could not be found:")
|
||||
print_section(f"📁 EXTRA FILES DISCOVERY ({component_name})", logger=self.summary_logger)
|
||||
print_prompt(
|
||||
"The following extra files were referenced in your configuration",
|
||||
style="default",
|
||||
logger=self.summary_logger,
|
||||
)
|
||||
print_prompt("but could not be found:", style="default", logger=self.summary_logger)
|
||||
|
||||
for file_path in self.missing_file_paths:
|
||||
self.pretty_logger.info(f"📝 Missing: {file_path.config_key} ({file_path.source_path})")
|
||||
print_prompt(
|
||||
f"📝 Missing: {file_path.config_key} ({file_path.source_path})",
|
||||
style="default",
|
||||
logger=self.summary_logger,
|
||||
)
|
||||
|
||||
self.pretty_logger.info("\n🔍 Would you like to:")
|
||||
self.pretty_logger.info(" 1. Provide alternative path for this file")
|
||||
self.pretty_logger.info(" 2. Skip these files and continue")
|
||||
self.pretty_logger.info(" 3. Provide a directory to search for files")
|
||||
print_prompt("\n🔍 Would you like to:", style="default", logger=self.summary_logger)
|
||||
print_prompt(" 1. Provide alternative path for this file", style="default", logger=self.summary_logger)
|
||||
print_prompt(" 2. Skip these files and continue", style="default", logger=self.summary_logger)
|
||||
print_prompt(" 3. Provide a directory to search for files", style="default", logger=self.summary_logger)
|
||||
|
||||
choice = prompt_choice(
|
||||
self.pretty_logger,
|
||||
self.summary_logger,
|
||||
"Enter your choice (1/2/3):",
|
||||
[
|
||||
"Provide alternative path for this file",
|
||||
"Skip these files and continue",
|
||||
"Provide a directory to search for files",
|
||||
],
|
||||
global_options=self.global_options,
|
||||
)
|
||||
|
||||
if choice == "Provide alternative path for this file":
|
||||
@@ -273,7 +287,7 @@ class ExtraFilesDiscovery:
|
||||
self._prompt_for_individual_alternatives(file_path)
|
||||
elif choice == "Skip these files and continue":
|
||||
# Skip missing files
|
||||
self.pretty_logger.info(" ⚠️ Skipping missing files...")
|
||||
print_prompt(" ⚠️ Skipping missing files...", style="default", logger=self.summary_logger)
|
||||
file_path.skipped_reason = "Skipped by user"
|
||||
elif choice == "Provide a directory to search for files":
|
||||
# Provide directory to search
|
||||
@@ -302,27 +316,32 @@ class ExtraFilesDiscovery:
|
||||
|
||||
while True:
|
||||
new_path = prompt_value(
|
||||
self.pretty_logger,
|
||||
self.summary_logger,
|
||||
"Please enter the correct file path (or 'skip' to ignore):",
|
||||
validator=validate_file_path,
|
||||
global_options=self.global_options,
|
||||
)
|
||||
|
||||
if new_path.lower() == "skip":
|
||||
self.pretty_logger.info(f" ⚠️ Skipping file: {discovered_path.source_path}")
|
||||
print_prompt(
|
||||
f" ⚠️ Skipping file: {discovered_path.source_path}", style="default", logger=self.summary_logger
|
||||
)
|
||||
break
|
||||
|
||||
new_path_obj = Path(new_path)
|
||||
discovered_extra_file = self._discover_extra_file(discovered_path, new_path_obj)
|
||||
if discovered_extra_file:
|
||||
self.discovered_extra_files[new_path_obj] = discovered_extra_file
|
||||
self.pretty_logger.info(f" ✅ File validated: {new_path}")
|
||||
print_prompt(f" ✅ File validated: {new_path}", style="default", logger=self.summary_logger)
|
||||
break
|
||||
|
||||
def _prompt_for_directory_search(self, discovered_path: DiscoveredPath) -> None:
|
||||
"""
|
||||
Prompt user for a directory to search for missing files.
|
||||
"""
|
||||
self.pretty_logger.info("\n📁 Please provide a directory to search for missing files:")
|
||||
print_prompt(
|
||||
"\n📁 Please provide a directory to search for missing files:", style="default", logger=self.summary_logger
|
||||
)
|
||||
|
||||
def validate_directory(path: str) -> tuple[bool, str]:
|
||||
if not path:
|
||||
@@ -337,9 +356,10 @@ class ExtraFilesDiscovery:
|
||||
|
||||
while True:
|
||||
search_dir = prompt_value(
|
||||
self.pretty_logger,
|
||||
self.summary_logger,
|
||||
"Enter directory path:",
|
||||
validator=validate_directory,
|
||||
global_options=self.global_options,
|
||||
)
|
||||
|
||||
dir_path = Path(search_dir)
|
||||
@@ -348,20 +368,27 @@ class ExtraFilesDiscovery:
|
||||
found_files = self._handle_directory(discovered_path, dir_path)
|
||||
|
||||
if found_files:
|
||||
self.pretty_logger.info(f" ✅ Found {len(found_files)} matching files in {search_dir}")
|
||||
print_prompt(
|
||||
f" ✅ Found {len(found_files)} matching files in {search_dir}",
|
||||
style="default",
|
||||
logger=self.summary_logger,
|
||||
)
|
||||
for file_path in found_files:
|
||||
self.pretty_logger.info(f" 📄 {Path(file_path).name}")
|
||||
print_prompt(f" 📄 {Path(file_path).name}", style="default", logger=self.summary_logger)
|
||||
break
|
||||
else:
|
||||
self.pretty_logger.info(f" ⚠️ No matching files found in {search_dir}")
|
||||
self.pretty_logger.info(" Would you like to try another directory?")
|
||||
print_prompt(
|
||||
f" ⚠️ No matching files found in {search_dir}", style="default", logger=self.summary_logger
|
||||
)
|
||||
print_prompt(" Would you like to try another directory?", style="default", logger=self.summary_logger)
|
||||
retry = prompt_yes_no(
|
||||
self.pretty_logger,
|
||||
self.summary_logger,
|
||||
"Try another directory?",
|
||||
default=False,
|
||||
global_options=self.global_options,
|
||||
)
|
||||
if not retry:
|
||||
self.pretty_logger.info(" ⚠️ Skipping directory search...")
|
||||
print_prompt(" ⚠️ Skipping directory search...", style="default", logger=self.summary_logger)
|
||||
break
|
||||
|
||||
def validate_extra_files(self) -> None:
|
||||
@@ -376,8 +403,10 @@ class ExtraFilesDiscovery:
|
||||
# Only print validation message if there were files to validate
|
||||
if self.discovered_file_paths or self.discovered_extra_files:
|
||||
component_name = self.strategy.component_name
|
||||
self.pretty_logger.info(f"\n✅ Extra files validation completed ({component_name})")
|
||||
print_separator(logger=self.pretty_logger)
|
||||
print_prompt(
|
||||
f"✅ Extra files validation completed ({component_name})", style="default", logger=self.summary_logger
|
||||
)
|
||||
print_separator(logger=self.summary_logger)
|
||||
|
||||
def _is_binary_file(self, path: Path) -> bool:
|
||||
"""
|
||||
|
||||
@@ -172,9 +172,10 @@ class ConfigValueTransformer:
|
||||
source and target paths.
|
||||
"""
|
||||
|
||||
pretty_logger: logging.Logger = field(init=True) # Pretty logger
|
||||
summary_logger: logging.Logger = field(init=True) # Pretty logger
|
||||
ess_config: dict[str, Any] = field(init=True) # Target ESS configuration dictionary
|
||||
value_source_tracking: ValueSourceTracking = field(init=True) # Shared value source tracking instance
|
||||
global_options: GlobalOptions = field(init=True) # Global options
|
||||
results: list[TransformationResult] = field(default_factory=list) # List of transformation results
|
||||
override_warnings: list[str] = field(default_factory=list) # Warnings about ESS-managed overrides
|
||||
underride_warnings: list[str] = field(default_factory=list) # Warnings about ESS default configurations
|
||||
@@ -212,6 +213,7 @@ class ConfigValueTransformer:
|
||||
self,
|
||||
value,
|
||||
extra_files_discovery=extra_files_discovery,
|
||||
global_options=self.global_options,
|
||||
**kwargs,
|
||||
)
|
||||
else:
|
||||
@@ -382,7 +384,7 @@ class ConfigValueTransformer:
|
||||
f"Skipping large file {discovered_extra_file.source_path} "
|
||||
f"({discovered_extra_file.source_path.stat().st_size} bytes > {MAX_EXTRA_FILE_SIZE} bytes)"
|
||||
)
|
||||
press_enter_to_continue(pretty_logger=self.pretty_logger)
|
||||
press_enter_to_continue(self.summary_logger, self.global_options)
|
||||
continue
|
||||
|
||||
# Read content from source_path (lazy loading - content read once here, not during discovery)
|
||||
@@ -452,7 +454,7 @@ class MigrationService:
|
||||
"""Migration service."""
|
||||
|
||||
input: MigrationInput = field(init=True) # Migration input data
|
||||
pretty_logger: logging.Logger = field(init=True) # Pretty logger
|
||||
summary_logger: logging.Logger = field(init=True) # Pretty logger
|
||||
ess_config: dict[str, Any] = field(init=True) # Target ESS configuration
|
||||
migration: MigrationStrategy = field(init=True) # Migration strategy
|
||||
extra_files_strategy: ExtraFilesDiscoveryStrategy = field(init=True) # Extra files discovery service
|
||||
@@ -489,7 +491,7 @@ class MigrationService:
|
||||
self.secret_discovery = SecretDiscovery(
|
||||
strategy=self.secret_discovery_strategy,
|
||||
source_file=self.input.config_path,
|
||||
pretty_logger=self.pretty_logger,
|
||||
summary_logger=self.summary_logger,
|
||||
global_options=self.global_options,
|
||||
secret_tracking=self.secret_tracking,
|
||||
)
|
||||
@@ -504,7 +506,8 @@ class MigrationService:
|
||||
source_file=self.input.config_path,
|
||||
strategy=self.extra_files_strategy,
|
||||
secrets_strategy=self.secret_discovery_strategy,
|
||||
pretty_logger=self.pretty_logger,
|
||||
summary_logger=self.summary_logger,
|
||||
global_options=self.global_options,
|
||||
)
|
||||
extra_files_discovery.discover_extra_files_from_config(self.input.config)
|
||||
# Prompt for missing files then validate
|
||||
@@ -515,7 +518,7 @@ class MigrationService:
|
||||
self.missing_file_paths = extra_files_discovery.missing_file_paths
|
||||
|
||||
config_to_ess_transformer = ConfigValueTransformer(
|
||||
self.pretty_logger, self.ess_config, self.value_source_tracking
|
||||
self.summary_logger, self.ess_config, self.value_source_tracking, self.global_options
|
||||
)
|
||||
|
||||
# Set strategy name for source tracking
|
||||
@@ -575,7 +578,7 @@ class MigrationService:
|
||||
return
|
||||
|
||||
config_to_ess_transformer = ConfigValueTransformer(
|
||||
self.pretty_logger, self.ess_config, self.value_source_tracking
|
||||
self.summary_logger, self.ess_config, self.value_source_tracking, self.global_options
|
||||
)
|
||||
config_to_ess_transformer.strategy_name = self.migration.name
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ class GlobalOptions:
|
||||
"""
|
||||
|
||||
use_existing_database: bool | None = None
|
||||
quiet_mode: bool | None = None
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
@@ -51,8 +51,6 @@ def write_outputs(
|
||||
Returns:
|
||||
Tuple of (values_path, secret_paths, configmap_paths)
|
||||
"""
|
||||
# Validate and create output directory
|
||||
_create_output_dir(output_dir)
|
||||
|
||||
# Write Helm values with error handling
|
||||
values_path = _write_helm_values(helm_values, output_dir)
|
||||
@@ -74,7 +72,7 @@ def write_outputs(
|
||||
return values_path, written_secrets, written_configmaps
|
||||
|
||||
|
||||
def _create_output_dir(output_dir: str) -> None:
|
||||
def create_output_dir(output_dir: str) -> None:
|
||||
"""
|
||||
Validate and create output directory.
|
||||
|
||||
|
||||
@@ -21,6 +21,8 @@ from rich.table import Table
|
||||
from rich.text import Text
|
||||
from rich.tree import Tree
|
||||
|
||||
from .models import GlobalOptions
|
||||
|
||||
# Global console instance
|
||||
_console: Console | None = None
|
||||
|
||||
@@ -46,8 +48,8 @@ def is_rich_enabled() -> bool:
|
||||
def print_table(
|
||||
data: list[list[str | Any]],
|
||||
headers: list[str],
|
||||
logger: logging.Logger,
|
||||
title: str = "",
|
||||
logger: logging.Logger | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
Print data in a formatted table using Rich if available, otherwise use plain text.
|
||||
@@ -58,20 +60,16 @@ def print_table(
|
||||
title: Optional table title
|
||||
logger: Logger to use for fallback output
|
||||
"""
|
||||
if not is_rich_enabled():
|
||||
# Fallback to plain text using the provided logger
|
||||
if logger is not None:
|
||||
if title:
|
||||
logger.info(f"\n{title}")
|
||||
logger.info("-" * len(title))
|
||||
# Print headers
|
||||
logger.info(" ".join(headers))
|
||||
# Print separator
|
||||
logger.info("-" * (sum(len(h) for h in headers) + 2 * (len(headers) - 1)))
|
||||
# Print rows
|
||||
for row in data:
|
||||
logger.info(" ".join(str(cell) for cell in row))
|
||||
return
|
||||
if title:
|
||||
logger.info(f"{title}")
|
||||
logger.info("-" * len(title))
|
||||
# Print headers
|
||||
logger.info(" ".join(headers))
|
||||
# Print separator
|
||||
logger.info("-" * (sum(len(h) for h in headers) + 2 * (len(headers) - 1)))
|
||||
# Print rows
|
||||
for row in data:
|
||||
logger.info(" ".join(str(cell) for cell in row))
|
||||
|
||||
# Rich is enabled - use styled table
|
||||
table = Table(
|
||||
@@ -95,9 +93,9 @@ def print_table(
|
||||
|
||||
def print_section(
|
||||
text: str,
|
||||
logger: logging.Logger,
|
||||
style: str = "bold cyan",
|
||||
border_style: str = "cyan",
|
||||
logger: logging.Logger | None = None,
|
||||
separator: str = "=",
|
||||
) -> None:
|
||||
"""
|
||||
@@ -110,12 +108,9 @@ def print_section(
|
||||
logger: Logger to use for fallback output
|
||||
separator: Character to use for separator line in plain text mode (default: "=")
|
||||
"""
|
||||
if not is_rich_enabled():
|
||||
# Fallback to plain text using the provided logger
|
||||
if logger is not None:
|
||||
logger.info(f"\n{text}")
|
||||
logger.info(separator * len(text))
|
||||
return
|
||||
# Log to file
|
||||
logger.info(text)
|
||||
logger.info(separator * len(text))
|
||||
|
||||
# Rich is enabled - use styled panel for section header
|
||||
panel = Panel(
|
||||
@@ -129,8 +124,8 @@ def print_section(
|
||||
|
||||
def print_header(
|
||||
text: str,
|
||||
logger: logging.Logger,
|
||||
style: str = "bold green",
|
||||
logger: logging.Logger | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
Print a styled header using Rich if available, otherwise use plain text.
|
||||
@@ -141,11 +136,8 @@ def print_header(
|
||||
style: Rich style string for the text (default: "bold green")
|
||||
logger: Logger to use for fallback output
|
||||
"""
|
||||
if not is_rich_enabled():
|
||||
# Fallback to plain text using the provided logger
|
||||
if logger is not None:
|
||||
logger.info(f"\n{text}")
|
||||
return
|
||||
# Log to file
|
||||
logger.info(text)
|
||||
|
||||
# Rich is enabled - use styled text without panel
|
||||
get_console().print(Text(text, style=style))
|
||||
@@ -153,7 +145,7 @@ def print_header(
|
||||
|
||||
def log_command(
|
||||
command: str,
|
||||
logger: logging.Logger | None = None,
|
||||
logger: logging.Logger,
|
||||
) -> None:
|
||||
"""
|
||||
Display a command with syntax highlighting using Rich.
|
||||
@@ -162,11 +154,7 @@ def log_command(
|
||||
command: The command string to display
|
||||
logger: Logger for fallback output when Rich is disabled
|
||||
"""
|
||||
if not is_rich_enabled():
|
||||
# Fallback to plain text using the provided logger
|
||||
if logger is not None:
|
||||
logger.info(f" {command}")
|
||||
return
|
||||
logger.info(f" {command}")
|
||||
|
||||
# Rich is enabled - use syntax highlighting
|
||||
syntax = Syntax(command, "bash", theme="monokai", word_wrap=True)
|
||||
@@ -175,8 +163,8 @@ def log_command(
|
||||
|
||||
def print_prompt(
|
||||
message: str,
|
||||
logger: logging.Logger,
|
||||
style: str = "bold",
|
||||
logger: logging.Logger | None = None,
|
||||
prefix: str = " ",
|
||||
) -> None:
|
||||
"""
|
||||
@@ -188,11 +176,7 @@ def print_prompt(
|
||||
logger: Logger to use for fallback output when Rich is disabled
|
||||
prefix: Prefix string to add before the message (default: " ")
|
||||
"""
|
||||
if not is_rich_enabled():
|
||||
# Fallback to plain text using the provided logger
|
||||
if logger is not None:
|
||||
logger.info(f"{prefix}{message}")
|
||||
return
|
||||
logger.info(f"{prefix}{message}")
|
||||
|
||||
# Rich is enabled - use styled text
|
||||
styled = Text(f"{prefix}{message}", style=style)
|
||||
@@ -200,7 +184,7 @@ def print_prompt(
|
||||
|
||||
|
||||
def print_separator(
|
||||
logger: logging.Logger | None = None,
|
||||
logger: logging.Logger,
|
||||
) -> None:
|
||||
"""
|
||||
Print a separator line using Rich styling if available.
|
||||
@@ -209,11 +193,7 @@ def print_separator(
|
||||
Args:
|
||||
logger: Logger to use for fallback output when Rich is disabled
|
||||
"""
|
||||
if not is_rich_enabled():
|
||||
# Fallback to plain text using the provided logger
|
||||
if logger is not None:
|
||||
logger.info("=" * 60)
|
||||
return
|
||||
logger.info("=" * 60)
|
||||
|
||||
# Rich is enabled - use a styled separator with terminal width
|
||||
console = get_console()
|
||||
@@ -224,7 +204,7 @@ def print_separator(
|
||||
def print_output_tree(
|
||||
output_dir: str,
|
||||
file_paths: list[str],
|
||||
logger: logging.Logger | None = None,
|
||||
logger: logging.Logger,
|
||||
) -> None:
|
||||
"""
|
||||
Print the output directory file tree using Rich styling if available.
|
||||
@@ -234,10 +214,7 @@ def print_output_tree(
|
||||
file_paths: List of file paths to display
|
||||
logger: Logger to use for fallback output when Rich is disabled
|
||||
"""
|
||||
if not is_rich_enabled():
|
||||
if logger is not None:
|
||||
logger.info(f"📁 Output files written to: {output_dir}")
|
||||
return
|
||||
logger.info(f"📁 Output files written to: {output_dir}")
|
||||
|
||||
console = get_console()
|
||||
output_path = Path(output_dir)
|
||||
@@ -266,8 +243,9 @@ class ProgressReporter:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
pretty_logger: logging.Logger,
|
||||
summary_logger: logging.Logger,
|
||||
steps: list[str],
|
||||
global_options: GlobalOptions,
|
||||
*,
|
||||
verbose: bool = False,
|
||||
) -> None:
|
||||
@@ -275,18 +253,19 @@ class ProgressReporter:
|
||||
Initialize the progress reporter.
|
||||
|
||||
Args:
|
||||
pretty_logger: Logger for output
|
||||
summary_logger: Logger for output
|
||||
steps: List of step names in order
|
||||
verbose: Enable verbose logging
|
||||
"""
|
||||
self.pretty_logger = pretty_logger
|
||||
self.summary_logger = summary_logger
|
||||
self.verbose = verbose
|
||||
self.current_step: int = -1
|
||||
self.all_steps = steps
|
||||
self.global_options = global_options
|
||||
|
||||
def start_migration(self) -> None:
|
||||
"""Report migration start."""
|
||||
print_header("🚀 Starting ESS Migration", logger=self.pretty_logger)
|
||||
print_header("🚀 Starting ESS Migration", logger=self.summary_logger)
|
||||
|
||||
def report_step(self, step_name: str) -> None:
|
||||
"""Report progress on a specific step."""
|
||||
@@ -313,11 +292,11 @@ class ProgressReporter:
|
||||
else:
|
||||
# Fallback to plain text for non-Rich environments
|
||||
step_msg_plain = f"📦 Step {self.current_step + 1}/{len(self.all_steps)} ({progress:.0f}%): {step_name}"
|
||||
self.pretty_logger.info(step_msg_plain)
|
||||
print_prompt(step_msg_plain, style="default", logger=self.summary_logger)
|
||||
|
||||
# Pause for user input after each step (unless in quiet mode or testing)
|
||||
if not os.environ.get("PYTEST_CURRENT_TEST") and self.pretty_logger.level != logging.CRITICAL:
|
||||
self.pretty_logger.info(" Press Enter to continue...")
|
||||
if not os.environ.get("PYTEST_CURRENT_TEST") and not self.global_options.quiet_mode:
|
||||
print_prompt(" Press Enter to continue...", style="default", logger=self.summary_logger)
|
||||
get_console().input()
|
||||
|
||||
def report_success(self, output_dir: str, file_paths: list[str]) -> None:
|
||||
@@ -327,14 +306,14 @@ class ProgressReporter:
|
||||
output_dir: Path to the output directory
|
||||
file_paths: Optional list of file paths that were written
|
||||
"""
|
||||
print_prompt("✅ Migration completed successfully!", logger=self.pretty_logger, style="bold green")
|
||||
print_output_tree(output_dir, file_paths, logger=self.pretty_logger)
|
||||
print_prompt("🎉 Ready to deploy with Element Server Suite!", logger=self.pretty_logger, style="bold magenta")
|
||||
print_prompt("✅ Migration completed successfully!", logger=self.summary_logger, style="bold green")
|
||||
print_output_tree(output_dir, file_paths, logger=self.summary_logger)
|
||||
print_prompt("🎉 Ready to deploy with Element Server Suite!", logger=self.summary_logger, style="bold magenta")
|
||||
|
||||
def report_failure(self, error: str) -> None:
|
||||
"""Report migration failure."""
|
||||
print_prompt("❌ Migration failed!", style="bold red", logger=self.pretty_logger, prefix="")
|
||||
print_prompt(f"💥 Error: {error}", style="bold red", logger=self.pretty_logger, prefix="")
|
||||
print_prompt("❌ Migration failed!", style="bold red", logger=self.summary_logger, prefix="")
|
||||
print_prompt(f"💥 Error: {error}", style="bold red", logger=self.summary_logger, prefix="")
|
||||
print_prompt(
|
||||
"📚 Check logs for details and try again.", style="bold yellow", logger=self.pretty_logger, prefix=""
|
||||
"📚 Check logs for details and try again.", style="bold yellow", logger=self.summary_logger, prefix=""
|
||||
)
|
||||
@@ -11,11 +11,10 @@ from dataclasses import dataclass, field
|
||||
|
||||
from .interfaces import SecretDiscoveryStrategy
|
||||
from .models import DiscoverableSecret, DiscoveredSecret, DiscoveredSecretTracking, GlobalOptions, SecretConfig
|
||||
from .rich_output import print_section, print_separator
|
||||
from .rich_output import print_prompt, print_section, print_separator
|
||||
from .utils import (
|
||||
find_matching_schema_key,
|
||||
get_nested_value,
|
||||
is_quiet_mode,
|
||||
is_wildcard_pattern,
|
||||
prompt_value,
|
||||
)
|
||||
@@ -34,7 +33,7 @@ class SecretDiscovery:
|
||||
"""Complete implementation that handles all secret discovery functionality."""
|
||||
|
||||
strategy: SecretDiscoveryStrategy = field(init=True) # Strategy for component-specific secret discovery
|
||||
pretty_logger: logging.Logger = field(init=True)
|
||||
summary_logger: logging.Logger = field(init=True)
|
||||
source_file: str = field(init=True) # Source configuration file name
|
||||
global_options: GlobalOptions = field(init=True) # Global migration options
|
||||
secret_tracking: DiscoveredSecretTracking = field(init=True) # Global tracking of discovered secrets
|
||||
@@ -280,7 +279,7 @@ class SecretDiscovery:
|
||||
return
|
||||
|
||||
# Check if quiet mode is enabled
|
||||
if is_quiet_mode(self.pretty_logger):
|
||||
if self.global_options.quiet_mode:
|
||||
missing_list = ", ".join(ds.secret_key for ds, _ in self.missing_required_secrets)
|
||||
raise SecretsError(
|
||||
f"Missing required {self.strategy.secret_name} secrets in quiet mode: {missing_list}. "
|
||||
@@ -288,9 +287,13 @@ class SecretDiscovery:
|
||||
)
|
||||
|
||||
component_name = self.strategy.secret_name.upper()
|
||||
print_section(f"🔐 {component_name} SECRETS REQUIRED FOR MIGRATION", logger=self.pretty_logger)
|
||||
self.pretty_logger.info(f"The following {component_name} secrets are required but could not be automatically")
|
||||
self.pretty_logger.info("discovered from your configuration files. Please provide them:")
|
||||
print_section(f"🔐 {component_name} SECRETS REQUIRED FOR MIGRATION", logger=self.summary_logger)
|
||||
print_prompt(
|
||||
f"The following {component_name} secrets are required but could not be automatically"
|
||||
"discovered from your configuration files. Please provide them:",
|
||||
style="default",
|
||||
logger=self.summary_logger,
|
||||
)
|
||||
|
||||
for discovered_secret, error_message in self.missing_required_secrets[:]:
|
||||
secret_key = discovered_secret.secret_key
|
||||
@@ -301,21 +304,24 @@ class SecretDiscovery:
|
||||
assert matching_schema_key is not None
|
||||
discoverable_secret = self.strategy.ess_secret_schema[matching_schema_key]
|
||||
|
||||
self.pretty_logger.info(f"📝 {discoverable_secret.description}")
|
||||
self.pretty_logger.info(f" Secret path: {secret_key}")
|
||||
print_prompt(f"📝 {discoverable_secret.description}", style="default", logger=self.summary_logger)
|
||||
print_prompt(f" Secret path: {secret_key}", style="default", logger=self.summary_logger)
|
||||
|
||||
# Add failure reason if available
|
||||
if error_message:
|
||||
self.pretty_logger.info(f" ⚠️ {error_message}")
|
||||
print_prompt(f" ⚠️ {error_message}", style="default", logger=self.summary_logger)
|
||||
if "Permission denied" in error_message:
|
||||
self.pretty_logger.info(" 💡 Use elevated privileges to read this file")
|
||||
print_prompt(
|
||||
" 💡 Use elevated privileges to read this file", style="default", logger=self.summary_logger
|
||||
)
|
||||
|
||||
if not config_key:
|
||||
raise RuntimeError(f"Missing configuration path for {secret_key}")
|
||||
|
||||
value = prompt_value(
|
||||
self.pretty_logger,
|
||||
self.summary_logger,
|
||||
"Please paste the secret value:",
|
||||
global_options=self.global_options,
|
||||
)
|
||||
self.discovered_secrets[secret_key] = DiscoveredSecret(
|
||||
source_file=self.source_file,
|
||||
@@ -325,7 +331,11 @@ class SecretDiscovery:
|
||||
)
|
||||
# Remove from missing_required_secrets after successful prompt
|
||||
self.missing_required_secrets.remove((discovered_secret, error_message))
|
||||
self.pretty_logger.info(f" ✅ Secret stored for {secret_key}")
|
||||
print_prompt(f" ✅ Secret stored for {secret_key}", style="default", logger=self.summary_logger)
|
||||
|
||||
self.pretty_logger.info(f"\n✅ All required {component_name} secrets have been provided")
|
||||
print_separator(logger=self.pretty_logger)
|
||||
print_prompt(
|
||||
f"✅ All required {component_name} secrets have been provided",
|
||||
style="default",
|
||||
logger=self.summary_logger,
|
||||
)
|
||||
print_separator(logger=self.summary_logger)
|
||||
@@ -16,6 +16,7 @@ from rapidfuzz import fuzz, process
|
||||
from .interfaces import ExtraFilesDiscoveryStrategy, SecretDiscoveryStrategy
|
||||
from .migration import ConfigValueTransformer, MigrationStrategy, TransformationSpec, additional_config_transformer
|
||||
from .models import DiscoverableSecret, DiscoveredSecret, GlobalOptions, MigrationError, SecretConfig
|
||||
from .rich_output import print_prompt
|
||||
from .utils import (
|
||||
extract_hostname_from_url,
|
||||
get_nested_value,
|
||||
@@ -61,22 +62,24 @@ def prompt_user_for_worker(
|
||||
instance_name: str,
|
||||
instance_props: Any,
|
||||
matched_worker_types: list[str],
|
||||
global_options: GlobalOptions,
|
||||
) -> str:
|
||||
if not matched_worker_types:
|
||||
matched_worker_types = worker_types
|
||||
|
||||
logger.info(" No worker type found for instance %s (host: %s)", instance_name, instance_props["host"])
|
||||
config_value_transformer.pretty_logger.info(
|
||||
f"\n ❌ No worker type found for instance {instance_name} (host: {instance_props['host']})"
|
||||
config_value_transformer.summary_logger.info(
|
||||
f" ❌ No worker type found for instance {instance_name} (host: {instance_props['host']})"
|
||||
)
|
||||
config_value_transformer.pretty_logger.info(" ❌ Available worker types")
|
||||
print_prompt(" ❌ Available worker types", style="default", logger=config_value_transformer.summary_logger)
|
||||
for i, worker_type in enumerate(matched_worker_types):
|
||||
config_value_transformer.pretty_logger.info(f" ❌ {i + 1}. {worker_type}")
|
||||
print_prompt(f" ❌ {i + 1}. {worker_type}", style="default", logger=config_value_transformer.summary_logger)
|
||||
|
||||
selected_worker = prompt_choice(
|
||||
config_value_transformer.pretty_logger,
|
||||
config_value_transformer.summary_logger,
|
||||
f"Please select the worker type of instance {instance_name}:",
|
||||
matched_worker_types,
|
||||
global_options,
|
||||
)
|
||||
return selected_worker
|
||||
|
||||
@@ -96,7 +99,11 @@ def extract_workers_from_instance_map(
|
||||
probable_matches = [m[0] for m in matches if m[1] > 60]
|
||||
selected_worker = (
|
||||
prompt_user_for_worker(
|
||||
config_value_transformer, instance_name, instance_map[instance_name], probable_matches
|
||||
config_value_transformer,
|
||||
instance_name,
|
||||
instance_map[instance_name],
|
||||
probable_matches,
|
||||
kwargs["global_options"],
|
||||
)
|
||||
if len(very_high_probable_matches) != 1
|
||||
else very_high_probable_matches[0]
|
||||
@@ -121,7 +128,11 @@ def extract_database_name(
|
||||
if not database_name:
|
||||
database_name = database_args.get("database")
|
||||
if not database_name:
|
||||
config_value_transformer.pretty_logger.info(" ❌ Synapse database name could not be found")
|
||||
print_prompt(
|
||||
" ❌ Synapse database name could not be found",
|
||||
style="default",
|
||||
logger=config_value_transformer.summary_logger,
|
||||
)
|
||||
raise MigrationError("No synapse database name found")
|
||||
return database_name
|
||||
|
||||
@@ -148,15 +159,26 @@ def prompt_for_ingress_host(
|
||||
return extract_hostname_from_url(config_value_transformer, public_baseurl)
|
||||
|
||||
# If public_baseurl is missing, prompt user for ingress host directly
|
||||
config_value_transformer.pretty_logger.info("\n ❌ Synapse public_baseurl not found in configuration")
|
||||
config_value_transformer.pretty_logger.info(
|
||||
" ❌ The chart requires Synapse Public BaseURL to be distinct from the server name"
|
||||
print_prompt(
|
||||
"\n ❌ Synapse public_baseurl not found in configuration",
|
||||
style="default",
|
||||
logger=config_value_transformer.summary_logger,
|
||||
)
|
||||
print_prompt(
|
||||
" ❌ The chart requires Synapse Public BaseURL to be distinct from the server name",
|
||||
style="default",
|
||||
logger=config_value_transformer.summary_logger,
|
||||
)
|
||||
print_prompt(
|
||||
" ❌ Please provide Synapse ingress host (e.g., matrix.example.com):",
|
||||
style="default",
|
||||
logger=config_value_transformer.summary_logger,
|
||||
)
|
||||
config_value_transformer.pretty_logger.info(" ❌ Please provide Synapse ingress host (e.g., matrix.example.com):")
|
||||
|
||||
return prompt_value(
|
||||
config_value_transformer.pretty_logger,
|
||||
config_value_transformer.summary_logger,
|
||||
"Enter ingress host:",
|
||||
kwargs["global_options"],
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import ec, rsa
|
||||
|
||||
from .models import MigrationError
|
||||
from .models import GlobalOptions, MigrationError
|
||||
from .rich_output import get_console, is_rich_enabled, print_prompt, print_section
|
||||
|
||||
|
||||
@@ -393,22 +393,6 @@ def detect_key_type(content: bytes) -> str:
|
||||
return "unknown"
|
||||
|
||||
|
||||
def is_quiet_mode(pretty_logger: logging.Logger) -> bool:
|
||||
"""
|
||||
Check if quiet mode is enabled by examining the logger level.
|
||||
|
||||
In the migration tool, quiet mode is indicated by setting the pretty_logger
|
||||
level to logging.CRITICAL, which suppresses all summary output.
|
||||
|
||||
Args:
|
||||
pretty_logger: The pretty logger instance to check
|
||||
|
||||
Returns:
|
||||
True if quiet mode is enabled (logger level is CRITICAL), False otherwise
|
||||
"""
|
||||
return pretty_logger.level == logging.CRITICAL
|
||||
|
||||
|
||||
def sort_tracked_values_for_filtering(tracked_values: list[str]) -> list[str]:
|
||||
"""
|
||||
Sort tracked values so that list indices are processed in descending order.
|
||||
@@ -451,63 +435,67 @@ def sort_tracked_values_for_filtering(tracked_values: list[str]) -> list[str]:
|
||||
return regular_paths + sorted_indexed
|
||||
|
||||
|
||||
def prompt_for_database_choice(pretty_logger: logging.Logger) -> bool:
|
||||
def prompt_for_database_choice(summary_logger: logging.Logger, global_options: GlobalOptions) -> bool:
|
||||
"""
|
||||
Prompt user to choose between using existing database or ESS-managed PostgreSQL.
|
||||
|
||||
Returns:
|
||||
True if user wants to use existing database, False for ESS-managed PostgreSQL
|
||||
"""
|
||||
print_section("🗃️ DATABASE CONFIGURATION CHOICE", logger=pretty_logger)
|
||||
if global_options.quiet_mode:
|
||||
raise MigrationError("Quiet mode is enabled. Cannot prompt for database choice.")
|
||||
|
||||
print_section("🗃️ DATABASE CONFIGURATION CHOICE", logger=summary_logger)
|
||||
print_prompt(
|
||||
"How would you like to handle the database for your ESS deployment?",
|
||||
style="bold white",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
prefix="",
|
||||
)
|
||||
print("")
|
||||
print_prompt("", logger=summary_logger)
|
||||
|
||||
print_prompt(
|
||||
"1. 🔗 Connect to existing database (recommended for production)",
|
||||
style="bold cyan",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
prefix="",
|
||||
)
|
||||
print_prompt("- Import your current database settings into ESS", style="dim", logger=pretty_logger, prefix=" ")
|
||||
print_prompt("- Continue using your existing PostgreSQL instance", style="dim", logger=pretty_logger, prefix=" ")
|
||||
print("")
|
||||
print_prompt("- Import your current database settings into ESS", style="dim", logger=summary_logger, prefix=" ")
|
||||
print_prompt("- Continue using your existing PostgreSQL instance", style="dim", logger=summary_logger, prefix=" ")
|
||||
print_prompt("", logger=summary_logger)
|
||||
print_prompt(
|
||||
"2. 🆕 Install PostgreSQL with ESS and import database later", style="white", logger=pretty_logger, prefix=""
|
||||
"2. 🆕 Install PostgreSQL with ESS and import database later", style="white", logger=summary_logger, prefix=""
|
||||
)
|
||||
print_prompt("- Let ESS deploy and manage PostgreSQL", style="dim", logger=pretty_logger, prefix=" ")
|
||||
print_prompt("- Let ESS deploy and manage PostgreSQL", style="dim", logger=summary_logger, prefix=" ")
|
||||
print_prompt(
|
||||
"- Import your Synapse and MAS database schemas after deployment",
|
||||
style="dim",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
prefix=" ",
|
||||
)
|
||||
print("")
|
||||
print_prompt("", logger=summary_logger)
|
||||
|
||||
choice = prompt_choice(
|
||||
pretty_logger,
|
||||
summary_logger,
|
||||
"Please select an option [1/2] (default: 1):",
|
||||
["Use existing database", "Install PostgreSQL with ESS"],
|
||||
default="Use existing database",
|
||||
global_options=global_options,
|
||||
)
|
||||
|
||||
if choice == "Use existing database":
|
||||
print_prompt("✅ Using existing database configuration", style="bold green", logger=pretty_logger)
|
||||
print_prompt("✅ Using existing database configuration", style="bold green", logger=summary_logger)
|
||||
return True
|
||||
else:
|
||||
print_prompt(
|
||||
"✅ Using ESS-managed PostgreSQL (import database later)", style="bold green", logger=pretty_logger
|
||||
"✅ Using ESS-managed PostgreSQL (import database later)", style="bold green", logger=summary_logger
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
def press_enter_to_continue(pretty_logger: logging.Logger) -> None:
|
||||
if not is_quiet_mode(pretty_logger) and not os.environ.get("PYTEST_CURRENT_TEST"):
|
||||
print_prompt("Press Enter to continue...", logger=pretty_logger)
|
||||
def press_enter_to_continue(summary_logger: logging.Logger, global_options: GlobalOptions) -> None:
|
||||
if not global_options.quiet_mode and not os.environ.get("PYTEST_CURRENT_TEST"):
|
||||
print_prompt("Press Enter to continue...", logger=summary_logger)
|
||||
if is_rich_enabled():
|
||||
get_console().input()
|
||||
else:
|
||||
@@ -515,8 +503,9 @@ def press_enter_to_continue(pretty_logger: logging.Logger) -> None:
|
||||
|
||||
|
||||
def prompt_value(
|
||||
pretty_logger: logging.Logger,
|
||||
summary_logger: logging.Logger,
|
||||
prompt: str,
|
||||
global_options: GlobalOptions,
|
||||
validator: Callable[[str], tuple[bool, str]] | None = None,
|
||||
default: str | None = None,
|
||||
) -> str:
|
||||
@@ -524,7 +513,7 @@ def prompt_value(
|
||||
Generic function to prompt user for a text value.
|
||||
|
||||
Args:
|
||||
pretty_logger: Logger for displaying prompts and messages
|
||||
summary_logger: Logger for displaying prompts and messages
|
||||
prompt: The prompt message to display
|
||||
validator: Optional function that takes input string and returns (is_valid, error_message)
|
||||
default: Optional default value if user presses Enter
|
||||
@@ -535,6 +524,9 @@ def prompt_value(
|
||||
Raises:
|
||||
MigrationError: If user cancels the operation (Ctrl+C or EOF)
|
||||
"""
|
||||
if global_options.quiet_mode:
|
||||
raise MigrationError("Quiet mode is enabled. Cannot prompt for value.")
|
||||
|
||||
while True:
|
||||
try:
|
||||
# Display prompt with Rich if available
|
||||
@@ -546,37 +538,38 @@ def prompt_value(
|
||||
|
||||
# Handle empty input
|
||||
if user_input == "":
|
||||
print_prompt("❌ Value cannot be empty. Please try again.", style="bold red", logger=pretty_logger)
|
||||
print_prompt("❌ Value cannot be empty. Please try again.", style="bold red", logger=summary_logger)
|
||||
continue
|
||||
|
||||
# Validate if validator is provided
|
||||
if validator is not None:
|
||||
is_valid, error_message = validator(user_input)
|
||||
if not is_valid:
|
||||
print_prompt(f"❌ {error_message}", style="bold red", logger=pretty_logger)
|
||||
print_prompt(f"❌ {error_message}", style="bold red", logger=summary_logger)
|
||||
continue
|
||||
|
||||
return user_input
|
||||
|
||||
except KeyboardInterrupt as err:
|
||||
print_prompt("\n❌ Operation cancelled by user", style="bold red", logger=pretty_logger, prefix="")
|
||||
print_prompt("\n❌ Operation cancelled by user", style="bold red", logger=summary_logger, prefix="")
|
||||
raise MigrationError("User cancelled input") from err
|
||||
except EOFError as err:
|
||||
print_prompt("\n❌ End of input reached", style="bold red", logger=pretty_logger, prefix="")
|
||||
print_prompt("\n❌ End of input reached", style="bold red", logger=summary_logger, prefix="")
|
||||
raise MigrationError("End of input reached during prompt") from err
|
||||
|
||||
|
||||
def prompt_choice(
|
||||
pretty_logger: logging.Logger,
|
||||
summary_logger: logging.Logger,
|
||||
prompt: str,
|
||||
options: list[str],
|
||||
global_options: GlobalOptions,
|
||||
default: str | None = None,
|
||||
) -> str:
|
||||
"""
|
||||
Prompt user to select from a numbered list of options.
|
||||
|
||||
Args:
|
||||
pretty_logger: Logger for displaying prompts and messages
|
||||
summary_logger: Logger for displaying prompts and messages
|
||||
prompt: The prompt message to display
|
||||
options: List of option strings to choose from
|
||||
default: Optional default choice (value, not index). If provided and user
|
||||
@@ -588,6 +581,9 @@ def prompt_choice(
|
||||
Raises:
|
||||
MigrationError: If user cancels the operation (Ctrl+C or EOF)
|
||||
"""
|
||||
if global_options.quiet_mode:
|
||||
raise MigrationError("Quiet mode is enabled. Cannot prompt for choice.")
|
||||
|
||||
while True:
|
||||
try:
|
||||
# Display prompt with Rich if available
|
||||
@@ -599,7 +595,7 @@ def prompt_choice(
|
||||
|
||||
# Handle empty input without default
|
||||
if user_input == "":
|
||||
print_prompt("❌ Please select a valid option.", style="bold red", logger=pretty_logger)
|
||||
print_prompt("❌ Please select a valid option.", style="bold red", logger=summary_logger)
|
||||
continue
|
||||
|
||||
# Try to parse as number
|
||||
@@ -611,33 +607,34 @@ def prompt_choice(
|
||||
print_prompt(
|
||||
f"❌ Invalid choice. Please enter a number between 1 and {len(options)}.",
|
||||
style="bold red",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
except ValueError:
|
||||
print_prompt(
|
||||
f"❌ Please enter a number between 1 and {len(options)}.",
|
||||
style="bold red",
|
||||
logger=pretty_logger,
|
||||
logger=summary_logger,
|
||||
)
|
||||
|
||||
except KeyboardInterrupt as err:
|
||||
print_prompt("\n❌ Operation cancelled by user", style="bold red", logger=pretty_logger, prefix="")
|
||||
print_prompt("\n❌ Operation cancelled by user", style="bold red", logger=summary_logger, prefix="")
|
||||
raise MigrationError("User cancelled input") from err
|
||||
except EOFError as err:
|
||||
print_prompt("\n❌ End of input reached", style="bold red", logger=pretty_logger, prefix="")
|
||||
print_prompt("\n❌ End of input reached", style="bold red", logger=summary_logger, prefix="")
|
||||
raise MigrationError("End of input reached during prompt") from err
|
||||
|
||||
|
||||
def prompt_yes_no(
|
||||
pretty_logger: logging.Logger,
|
||||
summary_logger: logging.Logger,
|
||||
prompt: str,
|
||||
global_options: GlobalOptions,
|
||||
default: bool | None = None,
|
||||
) -> bool:
|
||||
"""
|
||||
Prompt user for a yes/no answer.
|
||||
|
||||
Args:
|
||||
pretty_logger: Logger for displaying prompts and messages
|
||||
summary_logger: Logger for displaying prompts and messages
|
||||
prompt: The prompt message to display
|
||||
default: Optional default value if user presses Enter
|
||||
|
||||
@@ -647,6 +644,9 @@ def prompt_yes_no(
|
||||
Raises:
|
||||
MigrationError: If user cancels the operation (Ctrl+C or EOF)
|
||||
"""
|
||||
if global_options.quiet_mode:
|
||||
raise MigrationError("Quiet mode is enabled. Cannot prompt for input.")
|
||||
|
||||
while True:
|
||||
try:
|
||||
# Display prompt with Rich if available
|
||||
@@ -661,7 +661,7 @@ def prompt_yes_no(
|
||||
|
||||
# Handle empty input without default
|
||||
if user_input == "":
|
||||
print_prompt("❌ Please enter 'yes' or 'no'.", style="bold red", logger=pretty_logger)
|
||||
print_prompt("❌ Please enter 'yes' or 'no'.", style="bold red", logger=summary_logger)
|
||||
continue
|
||||
|
||||
# Check for yes variations
|
||||
@@ -671,11 +671,11 @@ def prompt_yes_no(
|
||||
elif user_input in ("no", "n", "false", "f", "0"):
|
||||
return False
|
||||
else:
|
||||
print_prompt("❌ Please enter 'yes' or 'no'.", style="bold red", logger=pretty_logger)
|
||||
print_prompt("❌ Please enter 'yes' or 'no'.", style="bold red", logger=summary_logger)
|
||||
|
||||
except KeyboardInterrupt as err:
|
||||
print_prompt("\n❌ Operation cancelled by user", style="bold red", logger=pretty_logger, prefix="")
|
||||
print_prompt("\n❌ Operation cancelled by user", style="bold red", logger=summary_logger, prefix="")
|
||||
raise MigrationError("User cancelled input") from err
|
||||
except EOFError as err:
|
||||
print_prompt("\n❌ End of input reached", style="bold red", logger=pretty_logger, prefix="")
|
||||
print_prompt("\n❌ End of input reached", style="bold red", logger=summary_logger, prefix="")
|
||||
raise MigrationError("End of input reached during prompt") from err
|
||||
@@ -16,7 +16,7 @@ from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import dsa, ec, rsa
|
||||
from ess_migration_tool.migration import ConfigValueTransformer
|
||||
from ess_migration_tool.models import ValueSourceTracking
|
||||
from ess_migration_tool.models import GlobalOptions, ValueSourceTracking
|
||||
|
||||
from .helm_validation import validate_helm_template
|
||||
|
||||
@@ -27,7 +27,10 @@ def config_value_transformer():
|
||||
|
||||
def _gen(name: str):
|
||||
return ConfigValueTransformer(
|
||||
logging.getLogger(name), ess_config={}, value_source_tracking=ValueSourceTracking()
|
||||
logging.getLogger(name),
|
||||
ess_config={},
|
||||
value_source_tracking=ValueSourceTracking(),
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
return _gen
|
||||
|
||||
@@ -161,10 +161,11 @@ def test_update_paths_in_config_basic(config_value_transformer):
|
||||
# Create ExtraFilesDiscovery instance
|
||||
extra_files_discovery = ExtraFilesDiscovery(
|
||||
strategy=MockStrategy(),
|
||||
pretty_logger=logging.Logger(__name__),
|
||||
summary_logger=logging.Logger(__name__),
|
||||
secrets_strategy=MockSecretStrategy(global_options=GlobalOptions()),
|
||||
source_file="test.yaml",
|
||||
discovered_file_paths=discovered_paths,
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Test the update_paths_in_config method
|
||||
@@ -231,10 +232,11 @@ def test_update_paths_in_config_with_skipped_paths(config_value_transformer):
|
||||
|
||||
extra_files_discovery = ExtraFilesDiscovery(
|
||||
strategy=MockStrategy(),
|
||||
pretty_logger=logging.Logger(__name__),
|
||||
summary_logger=logging.Logger(__name__),
|
||||
secrets_strategy=MockSecretStrategy(global_options=GlobalOptions()),
|
||||
source_file="test.yaml",
|
||||
discovered_file_paths=discovered_paths,
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Test the update_paths_in_config method
|
||||
@@ -286,10 +288,11 @@ def test_update_paths_in_config_empty_discovery(config_value_transformer):
|
||||
# Create ExtraFilesDiscovery with no discovered paths
|
||||
extra_files_discovery = ExtraFilesDiscovery(
|
||||
strategy=MockStrategy(),
|
||||
pretty_logger=logging.Logger(__name__),
|
||||
summary_logger=logging.Logger(__name__),
|
||||
secrets_strategy=MockSecretStrategy(global_options=GlobalOptions()),
|
||||
source_file="test.yaml",
|
||||
discovered_file_paths=[],
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Test the update_paths_in_config method
|
||||
@@ -356,10 +359,11 @@ def test_update_paths_in_config_nested_config(config_value_transformer):
|
||||
|
||||
extra_files_discovery = ExtraFilesDiscovery(
|
||||
strategy=MockStrategy(),
|
||||
pretty_logger=logging.Logger(__name__),
|
||||
summary_logger=logging.Logger(__name__),
|
||||
secrets_strategy=MockSecretStrategy(global_options=GlobalOptions()),
|
||||
source_file="test.yaml",
|
||||
discovered_file_paths=discovered_paths,
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Test the update_paths_in_config method
|
||||
|
||||
@@ -13,7 +13,7 @@ from pathlib import Path
|
||||
import pytest
|
||||
from ess_migration_tool.extra_files import ExtraFilesDiscovery, ExtraFilesError
|
||||
from ess_migration_tool.interfaces import ExtraFilesDiscoveryStrategy, SecretDiscoveryStrategy
|
||||
from ess_migration_tool.models import DiscoverableSecret, DiscoveredPath, SecretConfig
|
||||
from ess_migration_tool.models import DiscoverableSecret, DiscoveredPath, GlobalOptions, SecretConfig
|
||||
|
||||
|
||||
def test_validate_extra_files_success(tmp_path):
|
||||
@@ -41,13 +41,14 @@ def test_validate_extra_files_success(tmp_path):
|
||||
test2 = DiscoveredPath(config_key="b", source_file="test.yaml", source_path=tmp_path / "test2.yaml")
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
discovered_file_paths=[
|
||||
test1,
|
||||
test2,
|
||||
],
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Should validate successfully
|
||||
@@ -83,13 +84,14 @@ def test_validate_extra_files_missing():
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
discovered_file_paths=[
|
||||
DiscoveredPath(config_key="a", source_file="test.yaml", source_path="nonexistent/file1.txt"),
|
||||
DiscoveredPath(config_key="b", source_file="test.yaml", source_path="nonexistent/file2.yaml"),
|
||||
],
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Should raise ExtraFilesError
|
||||
@@ -121,9 +123,10 @@ def test_file_path_detection():
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Test various file path patterns
|
||||
@@ -171,9 +174,10 @@ def test_discover_file_paths_from_dict_and_list():
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
discovery._discover_file_paths_from_list_or_dict(config_data)
|
||||
|
||||
@@ -240,9 +244,10 @@ def test_mixed_config_with_secrets_and_extra_files():
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
discovery._discover_file_paths_from_list_or_dict(config_data)
|
||||
@@ -299,9 +304,10 @@ def test_duplicate_file_paths(tmp_path):
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
discovery.discover_extra_files_from_config(config_data)
|
||||
|
||||
@@ -354,9 +360,10 @@ def test_binary_file_detection(tmp_path):
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
discovery.discover_extra_files_from_config(config_data)
|
||||
|
||||
@@ -400,9 +407,10 @@ def test_ignored_config_keys():
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
discovery._discover_file_paths_from_list_or_dict(config_data)
|
||||
|
||||
@@ -450,9 +458,10 @@ def test_permission_error_handling(tmp_path):
|
||||
# Create discovery instance
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Discover file paths
|
||||
|
||||
@@ -25,7 +25,6 @@ def test_main_e2e_synapse_only(
|
||||
synapse_config_with_ca_federation_list,
|
||||
synapse_config_without_public_baseurl,
|
||||
write_synapse_config,
|
||||
capsys,
|
||||
helm_validator,
|
||||
):
|
||||
"""Test the complete end-to-end migration workflow with Synapse only."""
|
||||
@@ -48,7 +47,6 @@ def test_main_e2e_synapse_only(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -70,8 +68,7 @@ def test_main_e2e_synapse_only(
|
||||
assert exit_code == 0
|
||||
|
||||
# Get captured stderr output (where logging goes)
|
||||
captured = capsys.readouterr()
|
||||
log_output = captured.err
|
||||
log_output = next(output_dir.glob("*.log")).read_text()
|
||||
|
||||
# Verify override detection behavior
|
||||
# listeners should be filtered out (they serve chart-managed resources)
|
||||
@@ -226,7 +223,6 @@ def test_main_e2e_synapse_with_mas(
|
||||
basic_mas_config_with_keys,
|
||||
write_synapse_config,
|
||||
write_mas_config,
|
||||
capsys,
|
||||
helm_validator,
|
||||
):
|
||||
"""Test the complete end-to-end migration workflow with Synapse and MAS."""
|
||||
@@ -236,7 +232,6 @@ def test_main_e2e_synapse_with_mas(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -259,8 +254,7 @@ def test_main_e2e_synapse_with_mas(
|
||||
assert exit_code == 0
|
||||
|
||||
# Get captured stderr output (where logging goes)
|
||||
captured = capsys.readouterr()
|
||||
log_output = captured.err
|
||||
log_output = next(output_dir.glob("*.log")).read_text()
|
||||
|
||||
# Verify override detection behavior for MAS
|
||||
# http should be detected as override for MAS
|
||||
@@ -460,7 +454,6 @@ def test_main_e2e_mas_with_custom_listeners_and_ess_managed_database(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -541,7 +534,6 @@ def test_main_e2e_synapse_existing_database(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -605,7 +597,6 @@ def test_main_e2e_synapse_ess_managed_database(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -683,7 +674,6 @@ def test_main_e2e_synapse_listeners_with_custom_listeners(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -769,7 +759,6 @@ def test_main_e2e_mas_with_individual_keys(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -849,7 +838,6 @@ def test_main_e2e_synapse_with_mas_different_server_name(
|
||||
basic_mas_config_with_keys,
|
||||
write_synapse_config,
|
||||
write_mas_config,
|
||||
capsys,
|
||||
helm_validator,
|
||||
):
|
||||
"""Test conflict resolution when Synapse and MAS have different serverName values.
|
||||
@@ -872,7 +860,6 @@ def test_main_e2e_synapse_with_mas_different_server_name(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -922,8 +909,7 @@ def test_main_e2e_synapse_with_mas_different_server_name(
|
||||
assert generated_values["matrixAuthenticationService"]["enabled"] is True
|
||||
|
||||
# Verify the conflict prompt was shown in the output
|
||||
captured = capsys.readouterr()
|
||||
log_output = captured.err
|
||||
log_output = next(output_dir.glob("*.log")).read_text()
|
||||
assert "CONFLICT for 'serverName'" in log_output
|
||||
assert "synapse.example.com" in log_output
|
||||
assert "mas.example.com" in log_output
|
||||
@@ -937,7 +923,6 @@ def test_main_e2e_synapse_with_element_web(
|
||||
basic_element_web_config,
|
||||
write_synapse_config,
|
||||
write_element_web_config,
|
||||
capsys,
|
||||
helm_validator,
|
||||
):
|
||||
"""Test migration with Synapse and Element Web.
|
||||
@@ -958,7 +943,6 @@ def test_main_e2e_synapse_with_element_web(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -993,8 +977,7 @@ def test_main_e2e_synapse_with_element_web(
|
||||
assert success, f"Helm template validation failed: {message}"
|
||||
|
||||
# Get captured stderr output (where logging goes)
|
||||
captured = capsys.readouterr()
|
||||
log_output = captured.err
|
||||
log_output = next(output_dir.glob("*.log")).read_text()
|
||||
|
||||
# Verify Synapse configuration was migrated and is explicitly enabled
|
||||
assert "synapse" in generated_values
|
||||
@@ -1125,7 +1108,6 @@ def test_main_e2e_hookshot(
|
||||
synapse_config_with_signing_key,
|
||||
write_hookshot_config,
|
||||
write_synapse_config,
|
||||
capsys,
|
||||
helm_validator,
|
||||
):
|
||||
"""Test the complete end-to-end migration workflow with Hookshot."""
|
||||
@@ -1141,7 +1123,6 @@ def test_main_e2e_hookshot(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv to simulate CLI arguments
|
||||
test_args = [
|
||||
@@ -1165,8 +1146,7 @@ def test_main_e2e_hookshot(
|
||||
assert exit_code == 0
|
||||
|
||||
# Get captured stderr output (where logging goes)
|
||||
captured = capsys.readouterr()
|
||||
log_output = captured.err
|
||||
log_output = next(output_dir.glob("*.log")).read_text()
|
||||
|
||||
# Verify override detection behavior for Hookshot
|
||||
# bridge configs should be detected as overrides (except domain and url which are mapped to global values)
|
||||
@@ -1216,7 +1196,6 @@ def test_main_e2e_synapse_mas_shared_secret_conflict(
|
||||
basic_mas_config,
|
||||
write_synapse_config,
|
||||
write_mas_config,
|
||||
capsys,
|
||||
helm_validator,
|
||||
):
|
||||
"""Test conflict resolution for Synapse <-> MAS shared secret.
|
||||
@@ -1239,7 +1218,6 @@ def test_main_e2e_synapse_mas_shared_secret_conflict(
|
||||
|
||||
# Create output directory
|
||||
output_dir = tmp_path / "output"
|
||||
output_dir.mkdir()
|
||||
|
||||
# Mock sys.argv
|
||||
test_args = [
|
||||
@@ -1266,8 +1244,8 @@ def test_main_e2e_synapse_mas_shared_secret_conflict(
|
||||
assert exit_code == 0
|
||||
|
||||
# Verify the conflict prompt was shown
|
||||
captured = capsys.readouterr()
|
||||
log_output = captured.err
|
||||
log_output = next(output_dir.glob("*.log")).read_text()
|
||||
|
||||
assert "RESOLVING SECRET CONFLICTS" in log_output
|
||||
assert "Conflict for secret: matrixAuthenticationService.synapseSharedSecret" in log_output
|
||||
assert "• mas_side_secret (from: matrix-authentication-service)" in log_output
|
||||
|
||||
@@ -17,8 +17,10 @@ import pytest
|
||||
from ess_migration_tool.engine import MigrationEngine
|
||||
from ess_migration_tool.extra_files import ExtraFilesError
|
||||
from ess_migration_tool.inputs import InputProcessor
|
||||
from ess_migration_tool.models import GlobalOptions
|
||||
from ess_migration_tool.secrets import SecretsError
|
||||
from ess_migration_tool.synapse import SYNAPSE_STRATEGY_NAME, prompt_for_ingress_host
|
||||
from ess_migration_tool.utils import prompt_for_database_choice
|
||||
|
||||
|
||||
def test_migration_with_missing_secrets_prompt(
|
||||
@@ -44,15 +46,14 @@ def test_migration_with_missing_secrets_prompt(
|
||||
ess_values = {}
|
||||
|
||||
log_capture_string = StringIO()
|
||||
pretty_logger = logging.getLogger(test_migration_with_missing_secrets_prompt.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.INFO)
|
||||
pretty_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
logger = logging.getLogger(test_migration_with_missing_secrets_prompt.__name__)
|
||||
logger.propagate = False
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
|
||||
# Set database mode directly
|
||||
engine.global_options.use_existing_database = True
|
||||
global_options = GlobalOptions()
|
||||
global_options.use_existing_database = True
|
||||
engine = MigrationEngine(input_processor, summary_logger=logger, global_options=global_options)
|
||||
|
||||
# Mock user input for missing secrets
|
||||
side_effect = (n for n in ("test_db_password", "test_macaroon", "test_registration"))
|
||||
@@ -111,12 +112,12 @@ def test_migration_with_missing_secrets_prompt(
|
||||
|
||||
def test_prompt_for_ingress_host_with_missing_public_baseurl(monkeypatch, config_value_transformer):
|
||||
"""Test that missing public_baseurl triggers user prompt for ingress host."""
|
||||
pretty_logger = logging.getLogger(test_prompt_for_ingress_host_with_missing_public_baseurl.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.INFO)
|
||||
|
||||
log_capture_string = StringIO()
|
||||
pretty_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
logger = logging.getLogger(test_prompt_for_ingress_host_with_missing_public_baseurl.__name__)
|
||||
logger.propagate = False
|
||||
logger.setLevel(logging.INFO)
|
||||
|
||||
logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
# Mock user input using monkeypatch
|
||||
monkeypatch.setattr("builtins.input", lambda _: "matrix.example.com")
|
||||
@@ -124,7 +125,9 @@ def test_prompt_for_ingress_host_with_missing_public_baseurl(monkeypatch, config
|
||||
try:
|
||||
# Test with missing public_baseurl
|
||||
result = prompt_for_ingress_host(
|
||||
config_value_transformer(test_prompt_for_ingress_host_with_missing_public_baseurl.__name__), None
|
||||
config_value_transformer(test_prompt_for_ingress_host_with_missing_public_baseurl.__name__),
|
||||
None,
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
# Verify the result
|
||||
@@ -159,15 +162,13 @@ def test_quiet_mode_fails_on_missing_secrets(tmp_path, synapse_config_with_signi
|
||||
)
|
||||
|
||||
# Create logger in quiet mode (CRITICAL level)
|
||||
pretty_logger = logging.getLogger(test_quiet_mode_fails_on_missing_secrets.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.CRITICAL) # This simulates --quiet mode
|
||||
pretty_logger.addHandler(logging.StreamHandler())
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
logger = logging.getLogger(test_quiet_mode_fails_on_missing_secrets.__name__)
|
||||
logger.propagate = False
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
|
||||
# Set database mode directly to avoid prompting (simulate --database-mode existing)
|
||||
engine.global_options.use_existing_database = True
|
||||
global_options = GlobalOptions(use_existing_database=True, quiet_mode=True)
|
||||
engine = MigrationEngine(input_processor, summary_logger=logger, global_options=global_options)
|
||||
|
||||
# Test that it raises SecretsError in quiet mode
|
||||
with pytest.raises(SecretsError) as exc_info:
|
||||
@@ -197,15 +198,13 @@ def test_quiet_mode_fails_on_missing_extra_files(
|
||||
)
|
||||
|
||||
# Create logger in quiet mode (CRITICAL level)
|
||||
pretty_logger = logging.getLogger(test_quiet_mode_fails_on_missing_extra_files.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.CRITICAL) # This simulates --quiet mode
|
||||
pretty_logger.addHandler(logging.StreamHandler())
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
logger = logging.getLogger(test_quiet_mode_fails_on_missing_extra_files.__name__)
|
||||
logger.propagate = False
|
||||
logger.addHandler(logging.StreamHandler())
|
||||
|
||||
# Set database mode directly to avoid prompting (simulate --database-mode existing)
|
||||
engine.global_options.use_existing_database = True
|
||||
global_options = GlobalOptions(use_existing_database=True, quiet_mode=True)
|
||||
engine = MigrationEngine(input_processor, summary_logger=logger, global_options=global_options)
|
||||
|
||||
# Test that it raises ExtraFilesError in quiet mode
|
||||
with pytest.raises(ExtraFilesError) as exc_info:
|
||||
@@ -236,15 +235,14 @@ def test_migration_with_unknown_workers_prompt(
|
||||
ess_values = {}
|
||||
|
||||
log_capture_string = StringIO()
|
||||
pretty_logger = logging.getLogger(test_migration_with_unknown_workers_prompt.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.INFO)
|
||||
pretty_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
logger = logging.getLogger(test_migration_with_unknown_workers_prompt.__name__)
|
||||
logger.propagate = False
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
|
||||
# Set database mode directly
|
||||
engine.global_options.use_existing_database = True
|
||||
# Set database mode directly to avoid prompting (simulate --database-mode existing)
|
||||
global_options = GlobalOptions(use_existing_database=True)
|
||||
engine = MigrationEngine(input_processor, summary_logger=logger, global_options=global_options)
|
||||
|
||||
# Mock user input for workers
|
||||
side_effect = (n for n in ("8",))
|
||||
@@ -305,15 +303,14 @@ def test_migration_with_missing_extra_files_prompt(
|
||||
shutil.move(tmp_path / "email_templates", tmp_path / "moved")
|
||||
|
||||
log_capture_string = StringIO()
|
||||
pretty_logger = logging.getLogger(test_migration_with_missing_extra_files_prompt.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.INFO)
|
||||
pretty_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
logger = logging.getLogger(test_migration_with_missing_extra_files_prompt.__name__)
|
||||
logger.propagate = False
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
|
||||
# Set database mode directly
|
||||
engine.global_options.use_existing_database = True
|
||||
# Set database mode directly to avoid prompting (simulate --database-mode existing)
|
||||
global_options = GlobalOptions(use_existing_database=True)
|
||||
engine = MigrationEngine(input_processor, summary_logger=logger, global_options=global_options)
|
||||
|
||||
# Mock user input for extra files discovery
|
||||
side_effect = (n for n in ("3", str(tmp_path / "moved")))
|
||||
@@ -372,21 +369,18 @@ def test_database_choice_prompt_existing_database(
|
||||
)
|
||||
|
||||
log_capture_string = StringIO()
|
||||
pretty_logger = logging.getLogger(test_database_choice_prompt_existing_database.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.INFO)
|
||||
pretty_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
logger = logging.getLogger(test_database_choice_prompt_existing_database.__name__)
|
||||
logger.propagate = False
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=logger, global_options=GlobalOptions())
|
||||
|
||||
# Mock user input for database choice (select option 1 - existing database)
|
||||
side_effect = (n for n in ("1",)) # Just database choice, no missing secrets
|
||||
monkeypatch.setattr("builtins.input", lambda _: next(side_effect))
|
||||
|
||||
# Test database choice prompt directly
|
||||
from ess_migration_tool.utils import prompt_for_database_choice
|
||||
|
||||
engine.global_options.use_existing_database = prompt_for_database_choice(pretty_logger)
|
||||
engine.global_options.use_existing_database = prompt_for_database_choice(logger, engine.global_options)
|
||||
|
||||
# Test with async timeout to prevent hanging
|
||||
async def test_with_timeout():
|
||||
@@ -438,21 +432,18 @@ def test_database_choice_prompt_ess_managed(
|
||||
)
|
||||
|
||||
log_capture_string = StringIO()
|
||||
pretty_logger = logging.getLogger(test_database_choice_prompt_ess_managed.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.INFO)
|
||||
pretty_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
logger = logging.getLogger(test_database_choice_prompt_ess_managed.__name__)
|
||||
logger.propagate = False
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=logger, global_options=GlobalOptions())
|
||||
|
||||
# Mock user input for database choice (select option 2 - ESS-managed PostgreSQL)
|
||||
side_effect = (n for n in ("2",)) # Just database choice, no missing secrets
|
||||
monkeypatch.setattr("builtins.input", lambda _: next(side_effect))
|
||||
|
||||
# Test database choice prompt directly
|
||||
from ess_migration_tool.utils import prompt_for_database_choice
|
||||
|
||||
engine.global_options.use_existing_database = prompt_for_database_choice(pretty_logger)
|
||||
engine.global_options.use_existing_database = prompt_for_database_choice(logger, engine.global_options)
|
||||
|
||||
# Test with async timeout to prevent hanging
|
||||
async def test_with_timeout():
|
||||
@@ -504,21 +495,18 @@ def test_database_choice_prompt_default(
|
||||
)
|
||||
|
||||
log_capture_string = StringIO()
|
||||
pretty_logger = logging.getLogger(test_database_choice_prompt_default.__name__)
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.INFO)
|
||||
pretty_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
logger = logging.getLogger(test_database_choice_prompt_default.__name__)
|
||||
logger.propagate = False
|
||||
logger.setLevel(logging.INFO)
|
||||
logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=logger, global_options=GlobalOptions())
|
||||
|
||||
# Mock user input for database choice (press Enter for default - option 1)
|
||||
side_effect = (n for n in ("",)) # Empty string for default choice
|
||||
monkeypatch.setattr("builtins.input", lambda _: next(side_effect))
|
||||
|
||||
# Test database choice prompt directly
|
||||
from ess_migration_tool.utils import prompt_for_database_choice
|
||||
|
||||
engine.global_options.use_existing_database = prompt_for_database_choice(pretty_logger)
|
||||
engine.global_options.use_existing_database = prompt_for_database_choice(logger, engine.global_options)
|
||||
|
||||
# Test with async timeout to prevent hanging
|
||||
async def test_with_timeout():
|
||||
|
||||
@@ -163,11 +163,12 @@ def test_migration_output_schema_validation(tmp_path, synapse_config_with_signin
|
||||
config_path=synapse_path,
|
||||
)
|
||||
|
||||
# Create and run migration engine
|
||||
engine = MigrationEngine(input_processor=input_processor, pretty_logger=logging.getLogger())
|
||||
|
||||
# Set database mode directly to avoid prompting (simulate --database-mode existing)
|
||||
engine.global_options.use_existing_database = True
|
||||
global_options = GlobalOptions(use_existing_database=True)
|
||||
# Create and run migration engine
|
||||
engine = MigrationEngine(
|
||||
input_processor=input_processor, summary_logger=logging.getLogger(), global_options=global_options
|
||||
)
|
||||
|
||||
ess_values = engine.run_migration()
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ def test_secret_discovery_uses_tracking():
|
||||
discovery = SecretDiscovery(
|
||||
strategy=strategy,
|
||||
source_file="test.yaml",
|
||||
pretty_logger=logging.getLogger("test"),
|
||||
summary_logger=logging.getLogger("test"),
|
||||
global_options=global_options,
|
||||
secret_tracking=tracking,
|
||||
)
|
||||
@@ -137,7 +137,7 @@ def test_discovered_secret_registered_with_tracking():
|
||||
discovery = SecretDiscovery(
|
||||
strategy=strategy,
|
||||
source_file="test.yaml",
|
||||
pretty_logger=logging.getLogger("test"),
|
||||
summary_logger=logging.getLogger("test"),
|
||||
global_options=global_options,
|
||||
secret_tracking=tracking,
|
||||
)
|
||||
|
||||
@@ -104,7 +104,7 @@ def test_wildcard_secret_discovery_and_injection():
|
||||
strategy = MockWildcardStrategy(global_options, component_config)
|
||||
discovery = SecretDiscovery(
|
||||
strategy=strategy,
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
source_file="test.yaml",
|
||||
global_options=global_options,
|
||||
secret_tracking=DiscoveredSecretTracking(),
|
||||
@@ -121,9 +121,10 @@ def test_wildcard_secret_discovery_and_injection():
|
||||
# Use actual handle_secrets to inject credential configs
|
||||
secrets_list: list[Secret] = []
|
||||
transformer = ConfigValueTransformer(
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
ess_config={},
|
||||
value_source_tracking=ValueSourceTracking(),
|
||||
global_options=global_options,
|
||||
)
|
||||
|
||||
transformer.handle_secrets(discovery, secrets_list)
|
||||
@@ -261,7 +262,7 @@ def test_wildcard_secret_prompt_for_missing(monkeypatch: pytest.MonkeyPatch):
|
||||
|
||||
discovery = SecretDiscovery(
|
||||
strategy=strategy,
|
||||
pretty_logger=logging.getLogger("test"),
|
||||
summary_logger=logging.getLogger("test"),
|
||||
source_file="test.yaml",
|
||||
global_options=global_options,
|
||||
secret_tracking=DiscoveredSecretTracking(),
|
||||
|
||||
@@ -76,10 +76,11 @@ def test_discover_extra_files_from_synapse_config(tmp_path, synapse_config_with_
|
||||
# Start with basic config and add secret file references
|
||||
synapse_config = synapse_config_with_email_templates.copy()
|
||||
discovery = ExtraFilesDiscovery(
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=SynapseSecretDiscovery(GlobalOptions(use_existing_database=True)),
|
||||
strategy=SynapseExtraFileDiscovery(),
|
||||
source_file="homeserver.yaml",
|
||||
global_options=GlobalOptions(),
|
||||
)
|
||||
|
||||
discovery.discover_extra_files_from_config(synapse_config)
|
||||
|
||||
Reference in new issue
Block a user