Skip to content

Commit

Permalink
Revert "Implemented variable substitution for nested structures (#3665)"
Browse files Browse the repository at this point in the history
This reverts commit dda6937.
  • Loading branch information
jofsky authored Sep 28, 2023
1 parent dda6937 commit 61b288a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 34 deletions.
23 changes: 5 additions & 18 deletions cumulusci/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,26 +135,13 @@ def _init_options(self, kwargs):
self.options.update(kwargs)

# Handle dynamic lookup of project_config values via $project_config.attr
def process_options(option):
if isinstance(option, str):
return PROJECT_CONFIG_RE.sub(
for option, value in self.options.items():
if isinstance(value, str):
value = PROJECT_CONFIG_RE.sub(
lambda match: str(self.project_config.lookup(match.group(1), None)),
option,
value,
)
elif isinstance(option, dict):
processed_dict = {}
for key, value in option.items():
processed_dict[key] = process_options(value)
return processed_dict
elif isinstance(option, list):
processed_list = []
for item in option:
processed_list.append(process_options(item))
return processed_list
else:
return option

self.options = process_options(self.options)
self.options[option] = value

if self.Options:
try:
Expand Down
16 changes: 0 additions & 16 deletions cumulusci/core/tests/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,6 @@ def test_init_options__project_config_substitution(self):
task = BaseTask(self.project_config, self.task_config, self.org_config)
assert task.options["test_option"] == "baz"

# For variable substitution in nested structures
def test_init_options__project_config_substitution_nested(self):
self.project_config.config["foo"] = {"bar": "baz", "fighters": "pretender"}
self.project_config.config["vulf"] = {"peck": "DeanTown"}
self.task_config.config["options"] = {
"test_option": "$project_config.foo__bar",
"songs": [
{"foo_fighters": "$project_config.foo__fighters"},
{"vulfpeck": "$project_config.vulf__peck"},
],
}
task = BaseTask(self.project_config, self.task_config, self.org_config)
assert task.options["test_option"] == "baz"
assert task.options["songs"][0]["foo_fighters"] == "pretender"
assert task.options["songs"][1]["vulfpeck"] == "DeanTown"

def test_init_options__not_shared(self):
self.project_config.config["foo"] = {"bar": "baz"}
self.task_config.config["options"] = {}
Expand Down

0 comments on commit 61b288a

Please sign in to comment.