Skip to content

Fix to resolve env in key before merging #874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions core/src/main/python/wlsdeploy/util/cla_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,8 @@ def _get_merge_match_key(key, variable_map):
:param variable_map: variable map to use for substitutions
:return: the key to use for matching
"""
if variable_map is not None:
match_key = variables.substitute_key(key, variable_map)
else:
match_key = key

match_key = variables.substitute_key(key, variable_map)

if model_helper.is_delete_name(match_key):
match_key = model_helper.get_delete_item_name(match_key)
Expand Down
21 changes: 17 additions & 4 deletions core/src/main/python/wlsdeploy/util/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,11 +446,24 @@ def substitute_key(text, variables):
:param variables: the variable map
:return: the substituted text value
"""
matches = _property_pattern.findall(text)
method_name = "substitute_key"

if variables is not None:
matches = _property_pattern.findall(text)
for token, key in matches:
if key in variables:
value = variables[key]
text = text.replace(token, value)

matches = _environment_pattern.findall(text)
for token, key in matches:
if key in variables:
value = variables[key]
text = text.replace(token, value)
# log, or throw an exception if key is not found.
if not os.environ.has_key(key):
continue

value = os.environ.get(key)
text = text.replace(token, value)

return text


Expand Down
1 change: 1 addition & 0 deletions core/src/test/python/wlsdeploy/util/cla_helper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def testMergeModels(self):
}

variables = {}

cla_helper.merge_model_dictionaries(dictionary, new_dictionary, variables)
# print("Merged model: " + str(dictionary))

Expand Down