mirror of
https://github.com/element-hq/ess-helm.git
synced 2026-11-24 02:51:28 -08:00
Generate all output to a log file
This commit is contained in:
16 files changed
+446
-341
No files matched your search
@@ -9,6 +9,7 @@ Main CLI entry point for the migration script.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
|
||||
@@ -20,7 +21,7 @@ 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 .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,7 +158,14 @@ Examples:
|
||||
else:
|
||||
logger.setLevel(logging.CRITICAL)
|
||||
|
||||
pretty_logger = logging.getLogger("migration:summary")
|
||||
summary_logger = logging.getLogger("migration:summary")
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
summary_logger.addHandler(
|
||||
logging.FileHandler(f"output/migration-summary-{datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}.log")
|
||||
)
|
||||
|
||||
pretty_logger = logging.getLogger("migration:terminal")
|
||||
pretty_logger.propagate = False
|
||||
pretty_logger.setLevel(logging.CRITICAL if args.quiet else logging.INFO)
|
||||
pretty_sh = logging.StreamHandler()
|
||||
@@ -191,7 +199,7 @@ Examples:
|
||||
WRITING_OUTPUTS_STEP,
|
||||
]
|
||||
reporter = ProgressReporter(
|
||||
pretty_logger=pretty_logger,
|
||||
summary_logger=summary_logger,
|
||||
steps=steps,
|
||||
verbose=args.verbose,
|
||||
)
|
||||
@@ -235,7 +243,7 @@ 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)
|
||||
|
||||
# Set database mode if provided via command line
|
||||
if args.database_mode:
|
||||
@@ -245,7 +253,7 @@ 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)
|
||||
|
||||
ess_values = engine.run_migration()
|
||||
|
||||
@@ -266,8 +274,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)
|
||||
print_section("📊 MIGRATION SUMMARY", logger=summary_logger)
|
||||
|
||||
# Create a comprehensive mapping of source config paths to target ESS paths
|
||||
migration_mapping = {}
|
||||
@@ -297,9 +305,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)
|
||||
|
||||
if engine.ess_config["synapse"].get("workers"):
|
||||
# Prepare table data for workers
|
||||
@@ -310,14 +318,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)
|
||||
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)
|
||||
if engine.discovered_secrets:
|
||||
# Prepare table data for secrets
|
||||
secret_data = []
|
||||
@@ -333,9 +347,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)
|
||||
|
||||
if engine.init_by_ess_secrets:
|
||||
# Prepare table data for auto-generated secrets
|
||||
@@ -344,12 +358,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)
|
||||
|
||||
# Show override warnings within the migration summary
|
||||
if engine.override_warnings:
|
||||
@@ -359,21 +373,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)
|
||||
|
||||
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)
|
||||
|
||||
# Show underride warnings within the migration summary
|
||||
if engine.underride_warnings:
|
||||
@@ -383,53 +397,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)
|
||||
|
||||
# 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)
|
||||
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)
|
||||
|
||||
# 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)
|
||||
|
||||
# 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)
|
||||
|
||||
# Get the original media path from Synapse configuration
|
||||
synapse_input = engine.input_processor.input_for_strategy(SYNAPSE_STRATEGY_NAME)
|
||||
@@ -438,22 +462,37 @@ 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)
|
||||
|
||||
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)
|
||||
|
||||
# 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,
|
||||
)
|
||||
print_prompt(
|
||||
"existing database schema after deployment. Here are the steps:", style="default", logger=summary_logger
|
||||
)
|
||||
press_enter_to_continue(summary_logger)
|
||||
|
||||
# Get source database configuration from input files
|
||||
synapse_input = engine.input_processor.input_for_strategy(SYNAPSE_STRATEGY_NAME)
|
||||
@@ -482,32 +521,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)
|
||||
|
||||
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)
|
||||
step_number += 1
|
||||
|
||||
# Step 3: Transform the dumps (only show if transformations are needed)
|
||||
@@ -517,57 +564,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)
|
||||
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)
|
||||
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 +636,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)
|
||||
|
||||
print_separator(logger=pretty_logger)
|
||||
print_separator(logger=summary_logger)
|
||||
|
||||
reporter.report_success(args.output_dir, all_file_paths)
|
||||
logging.info("Migration completed successfully!")
|
||||
|
||||
@@ -11,12 +11,12 @@ import logging
|
||||
from typing import Any
|
||||
|
||||
from .models import DiscoveredSecretTracking, SecretSource, ValueSourceTracking
|
||||
from .rich_output import print_separator
|
||||
from .rich_output import print_prompt, print_separator
|
||||
from .utils import is_quiet_mode, 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]],
|
||||
display_value_max_length: int = 50,
|
||||
@@ -26,7 +26,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,14 +40,14 @@ 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)
|
||||
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],
|
||||
) -> None:
|
||||
@@ -64,7 +64,7 @@ def resolve_value_conflicts(
|
||||
logging.debug(f"Consistent values for {ess_path}: {first_value}")
|
||||
continue
|
||||
|
||||
if is_quiet_mode(pretty_logger):
|
||||
if is_quiet_mode(summary_logger):
|
||||
logging.info(f"Conflict detected for {ess_path}, using first value: {first_value}")
|
||||
continue
|
||||
|
||||
@@ -74,24 +74,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"\n⚠️ 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
|
||||
)
|
||||
|
||||
if is_custom:
|
||||
selected_value = prompt_value(pretty_logger, "Enter custom value:")
|
||||
selected_value = prompt_value(summary_logger, "Enter custom value:")
|
||||
|
||||
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,
|
||||
summary_logger: logging.Logger,
|
||||
secret_tracking: DiscoveredSecretTracking,
|
||||
) -> None:
|
||||
"""Resolve conflicts where multiple strategies discovered different values for the same secret."""
|
||||
@@ -101,15 +105,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 is_quiet_mode(summary_logger):
|
||||
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 +129,20 @@ 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)
|
||||
|
||||
if is_custom:
|
||||
new_value = prompt_value(pretty_logger, "Enter custom value:")
|
||||
new_value = prompt_value(summary_logger, "Enter custom value:")
|
||||
secret_tracking.sources[secret_key] = [
|
||||
SecretSource(
|
||||
strategy_name="user-provided",
|
||||
@@ -142,7 +154,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,7 @@ 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)
|
||||
ess_config: dict[str, Any] = field(default_factory=dict)
|
||||
secrets: list[Secret] = field(default_factory=list)
|
||||
configmaps: list[ConfigMap] = field(default_factory=list)
|
||||
@@ -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)
|
||||
|
||||
# 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)
|
||||
|
||||
# Disable any ESS component that was not migrated (absent from config)
|
||||
ALL_ESS_COMPONENTS = {
|
||||
|
||||
@@ -15,7 +15,7 @@ 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 .rich_output import print_prompt, print_section, print_separator
|
||||
from .utils import is_quiet_mode, prompt_choice, prompt_value, prompt_yes_no
|
||||
|
||||
logger = logging.getLogger("migration")
|
||||
@@ -39,7 +39,7 @@ 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
|
||||
@@ -177,16 +177,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 +238,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 is_quiet_mode(self.summary_logger) 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,20 +250,28 @@ 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",
|
||||
@@ -273,7 +285,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 +314,31 @@ 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,
|
||||
)
|
||||
|
||||
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,7 +353,7 @@ class ExtraFilesDiscovery:
|
||||
|
||||
while True:
|
||||
search_dir = prompt_value(
|
||||
self.pretty_logger,
|
||||
self.summary_logger,
|
||||
"Enter directory path:",
|
||||
validator=validate_directory,
|
||||
)
|
||||
@@ -348,20 +364,26 @@ 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,
|
||||
)
|
||||
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 +398,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"\n✅ 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,7 +172,7 @@ 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
|
||||
results: list[TransformationResult] = field(default_factory=list) # List of transformation results
|
||||
@@ -382,7 +382,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(summary_logger=self.summary_logger)
|
||||
continue
|
||||
|
||||
# Read content from source_path (lazy loading - content read once here, not during discovery)
|
||||
@@ -452,7 +452,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 +489,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 +504,7 @@ 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,
|
||||
)
|
||||
extra_files_discovery.discover_extra_files_from_config(self.input.config)
|
||||
# Prompt for missing files then validate
|
||||
@@ -515,7 +515,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
|
||||
)
|
||||
|
||||
# Set strategy name for source tracking
|
||||
@@ -575,7 +575,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
|
||||
)
|
||||
config_to_ess_transformer.strategy_name = self.migration.name
|
||||
|
||||
|
||||
@@ -46,8 +46,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 +58,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"\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))
|
||||
|
||||
# Rich is enabled - use styled table
|
||||
table = Table(
|
||||
@@ -95,9 +91,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 +106,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(f"\n{text}")
|
||||
logger.info(separator * len(text))
|
||||
|
||||
# Rich is enabled - use styled panel for section header
|
||||
panel = Panel(
|
||||
@@ -129,8 +122,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 +134,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(f"\n{text}")
|
||||
|
||||
# Rich is enabled - use styled text without panel
|
||||
get_console().print(Text(text, style=style))
|
||||
@@ -153,7 +143,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 +152,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 +161,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 +174,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 +182,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 +191,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 +202,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 +212,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,7 +241,7 @@ class ProgressReporter:
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
pretty_logger: logging.Logger,
|
||||
summary_logger: logging.Logger,
|
||||
steps: list[str],
|
||||
*,
|
||||
verbose: bool = False,
|
||||
@@ -275,18 +250,18 @@ 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
|
||||
|
||||
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 +288,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 self.summary_logger.level != logging.CRITICAL:
|
||||
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 +302,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,7 +11,7 @@ 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,
|
||||
@@ -34,7 +34,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 +280,7 @@ class SecretDiscovery:
|
||||
return
|
||||
|
||||
# Check if quiet mode is enabled
|
||||
if is_quiet_mode(self.pretty_logger):
|
||||
if is_quiet_mode(self.summary_logger):
|
||||
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 +288,17 @@ 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",
|
||||
style="default",
|
||||
logger=self.summary_logger,
|
||||
)
|
||||
print_prompt(
|
||||
"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,20 +309,22 @@ 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:",
|
||||
)
|
||||
self.discovered_secrets[secret_key] = DiscoveredSecret(
|
||||
@@ -325,7 +335,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"\n✅ 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,
|
||||
@@ -66,15 +67,15 @@ def prompt_user_for_worker(
|
||||
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(
|
||||
config_value_transformer.summary_logger.info(
|
||||
f"\n ❌ 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,
|
||||
)
|
||||
@@ -121,7 +122,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,14 +153,24 @@ 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:",
|
||||
)
|
||||
|
||||
|
||||
@@ -393,20 +393,20 @@ def detect_key_type(content: bytes) -> str:
|
||||
return "unknown"
|
||||
|
||||
|
||||
def is_quiet_mode(pretty_logger: logging.Logger) -> bool:
|
||||
def is_quiet_mode(summary_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
|
||||
In the migration tool, quiet mode is indicated by setting the summary_logger
|
||||
level to logging.CRITICAL, which suppresses all summary output.
|
||||
|
||||
Args:
|
||||
pretty_logger: The pretty logger instance to check
|
||||
summary_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
|
||||
return summary_logger.level == logging.CRITICAL
|
||||
|
||||
|
||||
def sort_tracked_values_for_filtering(tracked_values: list[str]) -> list[str]:
|
||||
@@ -451,18 +451,18 @@ 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) -> 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)
|
||||
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("")
|
||||
@@ -470,44 +470,44 @@ def prompt_for_database_choice(pretty_logger: logging.Logger) -> bool:
|
||||
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_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("")
|
||||
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("")
|
||||
|
||||
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",
|
||||
)
|
||||
|
||||
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) -> None:
|
||||
if not is_quiet_mode(summary_logger) 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,7 +515,7 @@ def press_enter_to_continue(pretty_logger: logging.Logger) -> None:
|
||||
|
||||
|
||||
def prompt_value(
|
||||
pretty_logger: logging.Logger,
|
||||
summary_logger: logging.Logger,
|
||||
prompt: str,
|
||||
validator: Callable[[str], tuple[bool, str]] | None = None,
|
||||
default: str | None = None,
|
||||
@@ -524,7 +524,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
|
||||
@@ -546,28 +546,28 @@ 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],
|
||||
default: str | None = None,
|
||||
@@ -576,7 +576,7 @@ def prompt_choice(
|
||||
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
|
||||
@@ -599,7 +599,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,25 +611,25 @@ 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,
|
||||
default: bool | None = None,
|
||||
) -> bool:
|
||||
@@ -637,7 +637,7 @@ def prompt_yes_no(
|
||||
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
|
||||
|
||||
@@ -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
|
||||
@@ -161,7 +161,7 @@ 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,
|
||||
@@ -231,7 +231,7 @@ 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,
|
||||
@@ -286,7 +286,7 @@ 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=[],
|
||||
@@ -356,7 +356,7 @@ 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,
|
||||
|
||||
@@ -41,7 +41,7 @@ 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=[
|
||||
@@ -83,7 +83,7 @@ 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=[
|
||||
@@ -121,7 +121,7 @@ def test_file_path_detection():
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
)
|
||||
@@ -171,7 +171,7 @@ 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",
|
||||
)
|
||||
@@ -240,7 +240,7 @@ 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",
|
||||
)
|
||||
@@ -299,7 +299,7 @@ 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",
|
||||
)
|
||||
@@ -354,7 +354,7 @@ 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",
|
||||
)
|
||||
@@ -400,7 +400,7 @@ def test_ignored_config_keys():
|
||||
|
||||
discovery = ExtraFilesDiscovery(
|
||||
strategy=TestStrategy(),
|
||||
pretty_logger=logging.getLogger(),
|
||||
summary_logger=logging.getLogger(),
|
||||
secrets_strategy=TestSecretStrategy(),
|
||||
source_file="test.yaml",
|
||||
)
|
||||
@@ -450,7 +450,7 @@ 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",
|
||||
)
|
||||
|
||||
@@ -44,12 +44,12 @@ 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))
|
||||
summary_logger = logging.getLogger(test_migration_with_missing_secrets_prompt.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
summary_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=summary_logger)
|
||||
|
||||
# Set database mode directly
|
||||
engine.global_options.use_existing_database = True
|
||||
@@ -111,12 +111,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)
|
||||
summary_logger = logging.getLogger(test_prompt_for_ingress_host_with_missing_public_baseurl.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
|
||||
log_capture_string = StringIO()
|
||||
pretty_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
summary_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
# Mock user input using monkeypatch
|
||||
monkeypatch.setattr("builtins.input", lambda _: "matrix.example.com")
|
||||
@@ -159,12 +159,12 @@ 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())
|
||||
summary_logger = logging.getLogger(test_quiet_mode_fails_on_missing_secrets.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.CRITICAL) # This simulates --quiet mode
|
||||
summary_logger.addHandler(logging.StreamHandler())
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=summary_logger)
|
||||
|
||||
# Set database mode directly to avoid prompting (simulate --database-mode existing)
|
||||
engine.global_options.use_existing_database = True
|
||||
@@ -197,12 +197,12 @@ 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())
|
||||
summary_logger = logging.getLogger(test_quiet_mode_fails_on_missing_extra_files.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.CRITICAL) # This simulates --quiet mode
|
||||
summary_logger.addHandler(logging.StreamHandler())
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=summary_logger)
|
||||
|
||||
# Set database mode directly to avoid prompting (simulate --database-mode existing)
|
||||
engine.global_options.use_existing_database = True
|
||||
@@ -236,12 +236,12 @@ 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))
|
||||
summary_logger = logging.getLogger(test_migration_with_unknown_workers_prompt.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
summary_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=summary_logger)
|
||||
|
||||
# Set database mode directly
|
||||
engine.global_options.use_existing_database = True
|
||||
@@ -305,12 +305,12 @@ 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))
|
||||
summary_logger = logging.getLogger(test_migration_with_missing_extra_files_prompt.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
summary_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=summary_logger)
|
||||
|
||||
# Set database mode directly
|
||||
engine.global_options.use_existing_database = True
|
||||
@@ -372,12 +372,12 @@ 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))
|
||||
summary_logger = logging.getLogger(test_database_choice_prompt_existing_database.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
summary_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=summary_logger)
|
||||
|
||||
# Mock user input for database choice (select option 1 - existing database)
|
||||
side_effect = (n for n in ("1",)) # Just database choice, no missing secrets
|
||||
@@ -386,7 +386,7 @@ def test_database_choice_prompt_existing_database(
|
||||
# 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(summary_logger)
|
||||
|
||||
# Test with async timeout to prevent hanging
|
||||
async def test_with_timeout():
|
||||
@@ -438,12 +438,12 @@ 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))
|
||||
summary_logger = logging.getLogger(test_database_choice_prompt_ess_managed.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
summary_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=summary_logger)
|
||||
|
||||
# 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
|
||||
@@ -452,7 +452,7 @@ def test_database_choice_prompt_ess_managed(
|
||||
# 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(summary_logger)
|
||||
|
||||
# Test with async timeout to prevent hanging
|
||||
async def test_with_timeout():
|
||||
@@ -504,12 +504,12 @@ 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))
|
||||
summary_logger = logging.getLogger(test_database_choice_prompt_default.__name__)
|
||||
summary_logger.propagate = False
|
||||
summary_logger.setLevel(logging.INFO)
|
||||
summary_logger.addHandler(logging.StreamHandler(log_capture_string))
|
||||
|
||||
engine = MigrationEngine(input_processor, pretty_logger=pretty_logger)
|
||||
engine = MigrationEngine(input_processor, summary_logger=summary_logger)
|
||||
|
||||
# Mock user input for database choice (press Enter for default - option 1)
|
||||
side_effect = (n for n in ("",)) # Empty string for default choice
|
||||
@@ -518,7 +518,7 @@ def test_database_choice_prompt_default(
|
||||
# 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(summary_logger)
|
||||
|
||||
# Test with async timeout to prevent hanging
|
||||
async def test_with_timeout():
|
||||
|
||||
@@ -164,7 +164,7 @@ def test_migration_output_schema_validation(tmp_path, synapse_config_with_signin
|
||||
)
|
||||
|
||||
# Create and run migration engine
|
||||
engine = MigrationEngine(input_processor=input_processor, pretty_logger=logging.getLogger())
|
||||
engine = MigrationEngine(input_processor=input_processor, summary_logger=logging.getLogger())
|
||||
|
||||
# Set database mode directly to avoid prompting (simulate --database-mode existing)
|
||||
engine.global_options.use_existing_database = True
|
||||
|
||||
@@ -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,7 +121,7 @@ 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(),
|
||||
)
|
||||
@@ -261,7 +261,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,7 +76,7 @@ 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",
|
||||
|
||||
Reference in new issue
Block a user