From 713ae2db0a3ba5f1c4507a9e4d4831641b0c6311 Mon Sep 17 00:00:00 2001 From: Zane Clark Date: Thu, 31 Oct 2024 13:26:48 -0700 Subject: [PATCH] feat: log get_merged_config steps --- schemachange/cli.py | 2 +- schemachange/config/get_merged_config.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/schemachange/cli.py b/schemachange/cli.py index d8c3325..f2b5dc3 100644 --- a/schemachange/cli.py +++ b/schemachange/cli.py @@ -42,7 +42,7 @@ def main(): % {"schemachange_version": SCHEMACHANGE_VERSION} ) - config = get_merged_config() + config = get_merged_config(logger=module_logger) redact_config_secrets(config_secrets=config.secrets) structlog.configure( diff --git a/schemachange/config/get_merged_config.py b/schemachange/config/get_merged_config.py index c1a868d..17f0831 100644 --- a/schemachange/config/get_merged_config.py +++ b/schemachange/config/get_merged_config.py @@ -3,6 +3,8 @@ from pathlib import Path from typing import Union, Optional +import structlog + from schemachange.config.DeployConfig import DeployConfig from schemachange.config.RenderConfig import RenderConfig from schemachange.config.parse_cli_args import parse_cli_args @@ -36,11 +38,16 @@ def get_yaml_config_kwargs(config_file_path: Optional[Path]) -> dict: return {k: v for k, v in kwargs.items() if v is not None} -def get_merged_config() -> Union[DeployConfig, RenderConfig]: +def get_merged_config( + logger: structlog.BoundLogger, +) -> Union[DeployConfig, RenderConfig]: env_kwargs: dict[str, str] = get_env_kwargs() + logger.info("env_kwargs", **env_kwargs) + connection_name = env_kwargs.pop("connection_name", None) cli_kwargs = parse_cli_args(sys.argv[1:]) + logger.info("cli_kwargs", **cli_kwargs) cli_config_vars = cli_kwargs.pop("config_vars") @@ -58,6 +65,8 @@ def get_merged_config() -> Union[DeployConfig, RenderConfig]: yaml_kwargs = get_yaml_config_kwargs( config_file_path=config_file_path, ) + logger.info("yaml_kwargs", **yaml_kwargs) + yaml_config_vars = yaml_kwargs.pop("config_vars", None) if yaml_config_vars is None: yaml_config_vars = {} @@ -77,6 +86,7 @@ def get_merged_config() -> Union[DeployConfig, RenderConfig]: connections_file_path=connections_file_path, connection_name=connection_name, ) + logger.info("connection_kwargs", **connection_kwargs) config_vars = { **yaml_config_vars, @@ -97,6 +107,8 @@ def get_merged_config() -> Union[DeployConfig, RenderConfig]: if connection_name is not None: kwargs["connection_name"] = connection_name + logger.info("final kwargs", **kwargs) + if cli_kwargs["subcommand"] == "deploy": return DeployConfig.factory(**kwargs) elif cli_kwargs["subcommand"] == "render":