mirror of
https://github.com/element-hq/ess-helm.git
synced 2026-11-24 02:51:28 -08:00
Rich prompts & separators
This commit is contained in:
7 files changed
+58
-15
No files matched your search
@@ -0,0 +1 @@
|
||||
Use Rich library to display formatted tables for migration mappings, workers, secrets, and warnings in the CLI output.
|
||||
@@ -18,7 +18,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_table
|
||||
from .rich_output import ProgressReporter, log_command, print_section, print_separator, print_table
|
||||
from .synapse import SYNAPSE_STRATEGY_NAME
|
||||
from .utils import press_enter_to_continue, prompt_for_database_choice
|
||||
|
||||
@@ -604,7 +604,7 @@ Examples:
|
||||
|
||||
press_enter_to_continue(pretty_logger)
|
||||
|
||||
pretty_logger.info("=" * 60)
|
||||
print_separator(logger=pretty_logger)
|
||||
|
||||
reporter.report_success(args.output_dir)
|
||||
logging.info("Migration completed successfully!")
|
||||
|
||||
@@ -11,6 +11,7 @@ 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
|
||||
|
||||
|
||||
@@ -101,9 +102,9 @@ def resolve_secret_conflicts(
|
||||
logger = logging.getLogger("migration")
|
||||
|
||||
pretty_logger.info("")
|
||||
pretty_logger.info("=" * 60)
|
||||
print_separator(logger=pretty_logger)
|
||||
pretty_logger.info("🔐 RESOLVING SECRET CONFLICTS")
|
||||
pretty_logger.info("=" * 60)
|
||||
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("")
|
||||
@@ -144,4 +145,4 @@ def resolve_secret_conflicts(
|
||||
pretty_logger.info(f" ✅ Resolved {secret_key}")
|
||||
pretty_logger.info("")
|
||||
|
||||
pretty_logger.info("=" * 60)
|
||||
print_separator(logger=pretty_logger)
|
||||
@@ -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
|
||||
from .rich_output import print_section, print_separator
|
||||
from .utils import is_quiet_mode, prompt_choice, prompt_value, prompt_yes_no
|
||||
|
||||
logger = logging.getLogger("migration")
|
||||
@@ -377,7 +377,7 @@ class ExtraFilesDiscovery:
|
||||
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})")
|
||||
self.pretty_logger.info("=" * 60)
|
||||
print_separator(logger=self.pretty_logger)
|
||||
|
||||
def _is_binary_file(self, path: Path) -> bool:
|
||||
"""
|
||||
|
||||
@@ -199,6 +199,28 @@ def print_prompt(
|
||||
get_console().print(styled)
|
||||
|
||||
|
||||
def print_separator(
|
||||
logger: logging.Logger | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
Print a separator line using Rich styling if available.
|
||||
Uses terminal width when Rich is enabled, falls back to 60 for plain text.
|
||||
|
||||
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
|
||||
|
||||
# Rich is enabled - use a styled separator with terminal width
|
||||
console = get_console()
|
||||
separator = "─" * console.width
|
||||
console.print(separator, style="cyan")
|
||||
|
||||
|
||||
class ProgressReporter:
|
||||
"""
|
||||
Handles progress reporting for the migration process.
|
||||
|
||||
@@ -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
|
||||
from .rich_output import print_section, print_separator
|
||||
from .utils import (
|
||||
find_matching_schema_key,
|
||||
get_nested_value,
|
||||
@@ -328,4 +328,4 @@ class SecretDiscovery:
|
||||
self.pretty_logger.info(f" ✅ Secret stored for {secret_key}")
|
||||
|
||||
self.pretty_logger.info(f"\n✅ All required {component_name} secrets have been provided")
|
||||
self.pretty_logger.info("=" * 60)
|
||||
print_separator(logger=self.pretty_logger)
|
||||
@@ -18,7 +18,7 @@ from cryptography.hazmat.primitives import serialization
|
||||
from cryptography.hazmat.primitives.asymmetric import ec, rsa
|
||||
|
||||
from .models import MigrationError
|
||||
from .rich_output import get_console, is_rich_enabled, print_prompt, print_section
|
||||
from .rich_output import is_rich_enabled, print_prompt, print_section
|
||||
|
||||
|
||||
def yaml_dump_with_pipe_for_multiline(data: Any) -> str:
|
||||
@@ -458,16 +458,33 @@ def prompt_for_database_choice(pretty_logger: logging.Logger) -> bool:
|
||||
True if user wants to use existing database, False for ESS-managed PostgreSQL
|
||||
"""
|
||||
print_section("🗃️ DATABASE CONFIGURATION CHOICE", logger=pretty_logger)
|
||||
print_prompt("How would you like to handle the database for your ESS deployment?", style="bold white", logger=pretty_logger, prefix="")
|
||||
print_prompt(
|
||||
"How would you like to handle the database for your ESS deployment?",
|
||||
style="bold white",
|
||||
logger=pretty_logger,
|
||||
prefix="",
|
||||
)
|
||||
print("")
|
||||
|
||||
print_prompt("1. 🔗 Connect to existing database (recommended for production)", style="bold cyan", logger=pretty_logger, prefix="")
|
||||
print_prompt(
|
||||
"1. 🔗 Connect to existing database (recommended for production)",
|
||||
style="bold cyan",
|
||||
logger=pretty_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("2. 🆕 Install PostgreSQL with ESS and import database later", style="white", logger=pretty_logger, prefix="")
|
||||
print_prompt(
|
||||
"2. 🆕 Install PostgreSQL with ESS and import database later", style="white", logger=pretty_logger, prefix=""
|
||||
)
|
||||
print_prompt("- Let ESS deploy and manage PostgreSQL", style="dim", logger=pretty_logger, prefix=" ")
|
||||
print_prompt("- Import your Synapse and MAS database schemas after deployment", style="dim", logger=pretty_logger, prefix=" ")
|
||||
print_prompt(
|
||||
"- Import your Synapse and MAS database schemas after deployment",
|
||||
style="dim",
|
||||
logger=pretty_logger,
|
||||
prefix=" ",
|
||||
)
|
||||
print("")
|
||||
|
||||
choice = prompt_choice(
|
||||
@@ -481,7 +498,9 @@ def prompt_for_database_choice(pretty_logger: logging.Logger) -> bool:
|
||||
print_prompt("✅ Using existing database configuration", style="bold green", logger=pretty_logger)
|
||||
return True
|
||||
else:
|
||||
print_prompt("✅ Using ESS-managed PostgreSQL (import database later)", style="bold green", logger=pretty_logger)
|
||||
print_prompt(
|
||||
"✅ Using ESS-managed PostgreSQL (import database later)", style="bold green", logger=pretty_logger
|
||||
)
|
||||
return False
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user