From 0bc59ad5132db29f0c54af1eee8da5da8623affb Mon Sep 17 00:00:00 2001 From: Richard Killen Date: Thu, 2 Apr 2020 12:17:11 -0500 Subject: [PATCH 1/2] Log at INFO level if WDT_MODEL_SECRETS_DIRS directory does not exist --- .../main/python/wlsdeploy/util/variables.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/src/main/python/wlsdeploy/util/variables.py b/core/src/main/python/wlsdeploy/util/variables.py index bfe6a0f136..d68079d468 100644 --- a/core/src/main/python/wlsdeploy/util/variables.py +++ b/core/src/main/python/wlsdeploy/util/variables.py @@ -357,15 +357,15 @@ def _init_secret_token_map(model_context): locations = os.environ.get(_secret_dirs_variable, _secret_dirs_default) for dir in locations.split(","): - if not os.path.isdir(dir): - # log at WARN or INFO, but no exception is thrown - log_method('WLSDPLY-01738', _secret_dirs_variable, dir, class_name=_class_name, method_name=method_name) - continue - - for subdir_name in os.listdir(dir): - subdir_path = os.path.join(dir, subdir_name) - if os.path.isdir(subdir_path): - _add_file_secrets_to_map(subdir_path, subdir_name, model_context) + if not os.path.isdir(dir): + # log at INFO, no exception is thrown + _logger.info('WLSDPLY-01738', _secret_dirs_variable, dir, class_name=_class_name, method_name=method_name) + continue + + for subdir_name in os.listdir(dir): + subdir_path = os.path.join(dir, subdir_name) + if os.path.isdir(subdir_path): + _add_file_secrets_to_map(subdir_path, subdir_name, model_context) # add name/key pairs for files in directories assigned in WDT_MODEL_SECRETS_NAME_DIR_PAIRS. # these pairs will override if they were previously added as sub-directory pairs. From cdeccfca1971147f99d2cc15158bee28f03bccd3 Mon Sep 17 00:00:00 2001 From: Richard Killen Date: Thu, 2 Apr 2020 14:12:34 -0500 Subject: [PATCH 2/2] Remove default value for WDT_MODEL_SECRETS_DIRS, skip if not set --- .../main/python/wlsdeploy/util/variables.py | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/core/src/main/python/wlsdeploy/util/variables.py b/core/src/main/python/wlsdeploy/util/variables.py index d68079d468..a2fe6d0416 100644 --- a/core/src/main/python/wlsdeploy/util/variables.py +++ b/core/src/main/python/wlsdeploy/util/variables.py @@ -34,7 +34,6 @@ _unresolved_token_pattern = re.compile("(@@(PROP|FILE|ENV|SECRET):)") _secret_dirs_variable = "WDT_MODEL_SECRETS_DIRS" -_secret_dirs_default = "/weblogic-operator/config-overrides-secrets" _secret_dir_pairs_variable="WDT_MODEL_SECRETS_NAME_DIR_PAIRS" _secret_token_map = None @@ -355,17 +354,19 @@ def _init_secret_token_map(model_context): # add name/key pairs for files in sub-directories of directories in WDT_MODEL_SECRETS_DIRS. - locations = os.environ.get(_secret_dirs_variable, _secret_dirs_default) - for dir in locations.split(","): - if not os.path.isdir(dir): - # log at INFO, no exception is thrown - _logger.info('WLSDPLY-01738', _secret_dirs_variable, dir, class_name=_class_name, method_name=method_name) - continue - - for subdir_name in os.listdir(dir): - subdir_path = os.path.join(dir, subdir_name) - if os.path.isdir(subdir_path): - _add_file_secrets_to_map(subdir_path, subdir_name, model_context) + locations = os.environ.get(_secret_dirs_variable, None) + if locations is not None: + for dir in locations.split(","): + if not os.path.isdir(dir): + # log at WARN or INFO, but no exception is thrown + log_method('WLSDPLY-01738', _secret_dirs_variable, dir, class_name=_class_name, + method_name=method_name) + continue + + for subdir_name in os.listdir(dir): + subdir_path = os.path.join(dir, subdir_name) + if os.path.isdir(subdir_path): + _add_file_secrets_to_map(subdir_path, subdir_name, model_context) # add name/key pairs for files in directories assigned in WDT_MODEL_SECRETS_NAME_DIR_PAIRS. # these pairs will override if they were previously added as sub-directory pairs.