forked from hitachienergy/epiphany
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for failing default merges... attempt 2 (hitachienergy#2258)
- Fix for failing default merges.
- Loading branch information
Showing
2 changed files
with
13 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,20 @@ | ||
from copy import deepcopy | ||
|
||
from cli.helpers.doc_list_helpers import select_first | ||
from cli.helpers.data_loader import load_all_yaml_objs, types | ||
from cli.helpers.objdict_helpers import merge_objdict | ||
from cli.helpers.objdict_helpers import merge_objdict, dict_to_objdict | ||
from cli.version import VERSION | ||
|
||
|
||
def merge_with_defaults(provider, feature_kind, config_selector, docs): | ||
files = load_all_yaml_objs(types.DEFAULT, provider, feature_kind) | ||
config_spec = select_first(files, lambda x: x.name == config_selector) | ||
if config_selector != 'default': | ||
default_config = select_first(docs, lambda x: x.name == 'default' and x.kind == feature_kind) | ||
if default_config is None: | ||
default_config = select_first(files, lambda x: x.name == 'default') | ||
default_config['version'] = VERSION | ||
merge_objdict(default_config, config_spec) | ||
return default_config | ||
default_config = dict_to_objdict(deepcopy(select_first(docs, lambda x: x.name == 'default' and x.kind == feature_kind))) | ||
default_doc = select_first(files, lambda x: x.name == 'default') | ||
if default_config is not None: | ||
merge_objdict(default_doc, default_config) | ||
merge_objdict(default_doc, config_spec) | ||
default_doc['version'] = VERSION | ||
return default_doc | ||
return config_spec |