From 80475b395a78963f79ef647a9da5d409a81795fd Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Tue, 27 Apr 2021 17:28:53 +0200 Subject: [PATCH 1/2] - Fix for failing default merges. --- core/src/epicli/cli/engine/schema/DefaultMerger.py | 3 +++ core/src/epicli/cli/helpers/config_merger.py | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/epicli/cli/engine/schema/DefaultMerger.py b/core/src/epicli/cli/engine/schema/DefaultMerger.py index 531f1d41fa..c250815e87 100644 --- a/core/src/epicli/cli/engine/schema/DefaultMerger.py +++ b/core/src/epicli/cli/engine/schema/DefaultMerger.py @@ -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 \ No newline at end of file diff --git a/core/src/epicli/cli/helpers/config_merger.py b/core/src/epicli/cli/helpers/config_merger.py index b5f6d6cb9f..6963d0b964 100644 --- a/core/src/epicli/cli/helpers/config_merger.py +++ b/core/src/epicli/cli/helpers/config_merger.py @@ -1,6 +1,8 @@ +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 @@ -8,9 +10,10 @@ 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 From e333c39b5f7f057930b4e5ac0250ec560eadd302 Mon Sep 17 00:00:00 2001 From: Luuk van Venrooij <11056665+seriva@users.noreply.github.com> Date: Wed, 28 Apr 2021 10:59:18 +0200 Subject: [PATCH 2/2] Minor fix when no defaults are definded. --- core/src/epicli/cli/helpers/config_merger.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/epicli/cli/helpers/config_merger.py b/core/src/epicli/cli/helpers/config_merger.py index 6963d0b964..aa872a6ef9 100644 --- a/core/src/epicli/cli/helpers/config_merger.py +++ b/core/src/epicli/cli/helpers/config_merger.py @@ -14,7 +14,7 @@ def merge_with_defaults(provider, feature_kind, config_selector, docs): 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 + merge_objdict(default_doc, config_spec) + default_doc['version'] = VERSION + return default_doc return config_spec