From 8fa61565cc3893eb1e012e989f5279c552b86640 Mon Sep 17 00:00:00 2001 From: AJ Steers Date: Tue, 20 Oct 2020 15:39:19 -0700 Subject: [PATCH] omit config file requirement --- tapdance/config.py | 14 +++++++++++--- tapdance/plans.py | 12 ++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tapdance/config.py b/tapdance/config.py index 745866b..9627bcb 100644 --- a/tapdance/config.py +++ b/tapdance/config.py @@ -98,6 +98,7 @@ def get_or_create_config( taps_dir: str = None, config_dir: str = None, config_file: str = None, + config_file_required: bool = True, ) -> Tuple[str, Dict[str, Any]]: """ Return a path to the configuration file and a dictionary of settings values. @@ -118,15 +119,22 @@ def get_or_create_config( tmp_path = f"{secrets_path}/tmp/{plugin_name}-config.json" orchestrator_env_vars = get_plugin_settings_from_env(plugin_name, meta_args=True) + expected_config_file_path = f"{secrets_path}/{plugin_name}-config.json" config_file = config_file or orchestrator_env_vars.get("CONFIG_FILE", None) - if (config_file is not None) and str(config_file).lower() == "false": - logging.info(f"Skipping check for '{plugin_name}' config (`config_file=False`)") + if ((config_file is not None) and str(config_file).lower() == "false") or ( + (not config_file_required) and not uio.file_exists(expected_config_file_path) + ): + logging.info( + f"Skipping check for '{plugin_name}' config " + f"(`config_file={config_file}`, " + f"`config_file_required={config_file_required}`)" + ) use_tmp_file = True config_file = tmp_path conf_dict = {} # Start with empty config orchestrator_settings = orchestrator_env_vars else: - config_file = config_file or f"{secrets_path}/{plugin_name}-config.json" + config_file = config_file or expected_config_file_path if not uio.file_exists(config_file): raise FileExistsError( f"Could not find '{plugin_name}' config at expected path: {config_file}" diff --git a/tapdance/plans.py b/tapdance/plans.py index 3ff9585..97262c3 100644 --- a/tapdance/plans.py +++ b/tapdance/plans.py @@ -563,22 +563,26 @@ def plan( config.print_version() taps_dir = config.get_taps_dir(taps_dir) + catalog_dir = config.get_tap_output_dir(tap_name, taps_dir) + raw_catalog_file = config.get_raw_catalog_file( + taps_dir, catalog_dir, tap_name, allow_custom=True + ) + config_file_required = True + if config_file is None and uio.file_exists(raw_catalog_file) and not rescan: + config_file_required = False config_file, tap_settings = config.get_or_create_config( f"tap-{tap_name}", taps_dir=taps_dir, config_dir=config_dir, config_file=config_file, + config_file_required=config_file_required, ) tap_exe = tap_exe or tap_settings.get("EXE", f"tap-{tap_name}") replication_strategy = replication_strategy or tap_settings.get( "REPLICATION_STRATEGY", "INCREMENTAL" ) config.validate_replication_strategy(replication_strategy) - catalog_dir = config.get_tap_output_dir(tap_name, taps_dir) log_dir = config.get_log_dir(log_dir) - raw_catalog_file = config.get_raw_catalog_file( - taps_dir, catalog_dir, tap_name, allow_custom=True - ) selected_catalog_file = f"{catalog_dir}/{tap_name}-catalog-selected.json" plan_file = config.get_plan_file(tap_name, taps_dir, required=False) if rescan or not uio.file_exists(raw_catalog_file):