Skip to content

Commit

Permalink
Fix for failing default merges... attempt 2 (hitachienergy#2258)
Browse files Browse the repository at this point in the history
 - Fix for failing default merges.
  • Loading branch information
seriva authored and sbbroot committed Aug 17, 2021
1 parent 658c9c9 commit 8f2953f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions core/src/epicli/cli/engine/schema/DefaultMerger.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def merge_parent(self, files, doc):
merged_parent['version'] = VERSION
merge_objdict(merged_parent, doc)
return merged_parent
default_config = select_first(self.docs, lambda x: x.name == 'default' and x.kind == doc.kind)
default_doc = select_first(files, lambda x: x.name == 'default')
if default_config is not None:
merge_objdict(default_doc, default_config)
default_doc['version'] = VERSION
merge_objdict(default_doc, doc)
return default_doc
17 changes: 10 additions & 7 deletions core/src/epicli/cli/helpers/config_merger.py
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

0 comments on commit 8f2953f

Please sign in to comment.