11"""
2- Copyright (c) 2017, 2022 , Oracle Corporation and/or its affiliates.
3- Licensed under the Universal Permissive License v 1 .0 as shown at https://oss.oracle.com/licenses/upl.
2+ Copyright (c) 2017, 2023 , Oracle Corporation and/or its affiliates.
3+ Licensed under the Universal Permissive License v1 .0 as shown at https://oss.oracle.com/licenses/upl.
44"""
55import os
66import re
2222from wlsdeploy .exception import exception_helper
2323from wlsdeploy .logging import platform_logger
2424from wlsdeploy .util import dictionary_utils
25+ from wlsdeploy .util import env_helper
2526from wlsdeploy .util .cla_utils import CommandLineArgUtil
2627
2728_class_name = "variables"
@@ -284,16 +285,16 @@ def _substitute(text, variables, model_context, error_info, attribute_name=None)
284285 #
285286 env_var_name = str_helper .to_string (key )
286287 is_windows = System .getProperty ('os.name' ).startswith ('Windows' )
287- if is_windows and env_var_name not in os . environ and env_var_name .upper () in os . environ :
288+ if is_windows and not env_helper . has_env ( env_var_name ) and env_var_name .has_env ( env_var_name . upper ()) :
288289 env_var_name = env_var_name .upper ()
289290
290- if env_var_name not in os . environ :
291+ if not env_helper . has_env ( env_var_name ) :
291292 allow_unresolved = validation_config .allow_unresolved_environment_tokens ()
292293 _report_token_issue ('WLSDPLY-01737' , method_name , allow_unresolved , key )
293294 _increment_error_count (error_info , allow_unresolved )
294295 problem_found = True
295296 continue
296- value = os . environ . get (env_var_name )
297+ value = env_helper . getenv (env_var_name )
297298 text = text .replace (token , value )
298299
299300 # check secret variables before @@FILE:/dir/@@SECRET:name:key@@.txt@@
@@ -420,7 +421,7 @@ def _init_secret_token_map(model_context):
420421
421422 # add name/key pairs for files in sub-directories of directories in WDT_MODEL_SECRETS_DIRS.
422423
423- locations = os . environ . get (str_helper .to_string (_secret_dirs_variable ), None )
424+ locations = env_helper . getenv (str_helper .to_string (_secret_dirs_variable ))
424425 if locations is not None :
425426 for secret_dir in locations .split ("," ):
426427 if not os .path .isdir (secret_dir ):
@@ -437,7 +438,7 @@ def _init_secret_token_map(model_context):
437438 # add name/key pairs for files in directories assigned in WDT_MODEL_SECRETS_NAME_DIR_PAIRS.
438439 # these pairs will override if they were previously added as sub-directory pairs.
439440
440- dir_pairs_text = os . environ . get (str_helper .to_string (_secret_dir_pairs_variable ), None )
441+ dir_pairs_text = env_helper . getenv (str_helper .to_string (_secret_dir_pairs_variable ))
441442 if dir_pairs_text is not None :
442443 dir_pairs = dir_pairs_text .split (',' )
443444 for dir_pair in dir_pairs :
@@ -533,10 +534,10 @@ def substitute_key(text, variables):
533534 matches = _environment_pattern .findall (text )
534535 for token , key in matches :
535536 # log, or throw an exception if key is not found.
536- if str_helper .to_string (key ) not in os . environ :
537+ if not env_helper . has_env ( str_helper .to_string (key )) :
537538 continue
538539
539- value = os . environ . get (str_helper .to_string (key ))
540+ value = env_helper . getenv (str_helper .to_string (key ))
540541 text = text .replace (token , value )
541542
542543 return text
0 commit comments