1
1
"""
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.
4
4
"""
5
5
import os
6
6
import re
22
22
from wlsdeploy .exception import exception_helper
23
23
from wlsdeploy .logging import platform_logger
24
24
from wlsdeploy .util import dictionary_utils
25
+ from wlsdeploy .util import env_helper
25
26
from wlsdeploy .util .cla_utils import CommandLineArgUtil
26
27
27
28
_class_name = "variables"
@@ -284,16 +285,16 @@ def _substitute(text, variables, model_context, error_info, attribute_name=None)
284
285
#
285
286
env_var_name = str_helper .to_string (key )
286
287
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 ()) :
288
289
env_var_name = env_var_name .upper ()
289
290
290
- if env_var_name not in os . environ :
291
+ if not env_helper . has_env ( env_var_name ) :
291
292
allow_unresolved = validation_config .allow_unresolved_environment_tokens ()
292
293
_report_token_issue ('WLSDPLY-01737' , method_name , allow_unresolved , key )
293
294
_increment_error_count (error_info , allow_unresolved )
294
295
problem_found = True
295
296
continue
296
- value = os . environ . get (env_var_name )
297
+ value = env_helper . getenv (env_var_name )
297
298
text = text .replace (token , value )
298
299
299
300
# check secret variables before @@FILE:/dir/@@SECRET:name:key@@.txt@@
@@ -420,7 +421,7 @@ def _init_secret_token_map(model_context):
420
421
421
422
# add name/key pairs for files in sub-directories of directories in WDT_MODEL_SECRETS_DIRS.
422
423
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 ))
424
425
if locations is not None :
425
426
for secret_dir in locations .split ("," ):
426
427
if not os .path .isdir (secret_dir ):
@@ -437,7 +438,7 @@ def _init_secret_token_map(model_context):
437
438
# add name/key pairs for files in directories assigned in WDT_MODEL_SECRETS_NAME_DIR_PAIRS.
438
439
# these pairs will override if they were previously added as sub-directory pairs.
439
440
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 ))
441
442
if dir_pairs_text is not None :
442
443
dir_pairs = dir_pairs_text .split (',' )
443
444
for dir_pair in dir_pairs :
@@ -533,10 +534,10 @@ def substitute_key(text, variables):
533
534
matches = _environment_pattern .findall (text )
534
535
for token , key in matches :
535
536
# 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 )) :
537
538
continue
538
539
539
- value = os . environ . get (str_helper .to_string (key ))
540
+ value = env_helper . getenv (str_helper .to_string (key ))
540
541
text = text .replace (token , value )
541
542
542
543
return text
0 commit comments