Skip to content

Commit 87d5c39

Browse files
authored
Fix to resolve env in key before merging (#874)
1 parent 9529004 commit 87d5c39

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

core/src/main/python/wlsdeploy/util/cla_helper.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,8 @@ def _get_merge_match_key(key, variable_map):
383383
:param variable_map: variable map to use for substitutions
384384
:return: the key to use for matching
385385
"""
386-
if variable_map is not None:
387-
match_key = variables.substitute_key(key, variable_map)
388-
else:
389-
match_key = key
386+
387+
match_key = variables.substitute_key(key, variable_map)
390388

391389
if model_helper.is_delete_name(match_key):
392390
match_key = model_helper.get_delete_item_name(match_key)

core/src/main/python/wlsdeploy/util/variables.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -446,11 +446,24 @@ def substitute_key(text, variables):
446446
:param variables: the variable map
447447
:return: the substituted text value
448448
"""
449-
matches = _property_pattern.findall(text)
449+
method_name = "substitute_key"
450+
451+
if variables is not None:
452+
matches = _property_pattern.findall(text)
453+
for token, key in matches:
454+
if key in variables:
455+
value = variables[key]
456+
text = text.replace(token, value)
457+
458+
matches = _environment_pattern.findall(text)
450459
for token, key in matches:
451-
if key in variables:
452-
value = variables[key]
453-
text = text.replace(token, value)
460+
# log, or throw an exception if key is not found.
461+
if not os.environ.has_key(key):
462+
continue
463+
464+
value = os.environ.get(key)
465+
text = text.replace(token, value)
466+
454467
return text
455468

456469

core/src/test/python/wlsdeploy/util/cla_helper_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def testMergeModels(self):
6060
}
6161

6262
variables = {}
63+
6364
cla_helper.merge_model_dictionaries(dictionary, new_dictionary, variables)
6465
# print("Merged model: " + str(dictionary))
6566

0 commit comments

Comments
 (0)