Skip to content
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

Fix for failing default merges... attempt 2 #2258

Merged
merged 2 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
11 changes: 7 additions & 4 deletions core/src/epicli/cli/helpers/config_merger.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
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 = 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)
default_config['version'] = VERSION
merge_objdict(default_config, config_spec)
return default_config
Expand Down