Restructure the setup config load order #818
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactor Configuration Load Order
Description
Improve the order in which the default configs and user-defined configs are loaded and merged in
setupinator
.Fixes #536, with thanks to my colleague @chuyingy
Previous structure
Previously, the config load order and result priority were as follows:
Previous config load procedure:
project.yml
withDEFAULT_CEEDLING_CONFIG
DEFAULT_TOOLS_*
,CMock
, andUnity
settings.plugin
settings.defaults
.Resulting priority order (highest first):
project.yml
DEFAULT_CEEDLING_CONFIG
DEFAULT_TOOLS_*
,CMock
, andUnity
plugin
settingsdefaults
This would result in some default settings having a higher priority than plugin settings. It also made the differences in behaviour between plugin settings and plugin defaults confusing as they were almost but not quite the same.
Proposed changes
The proposed change will first merge the user-defined configs and default configs separately, and then combine them. This approach ensures all user-defined configurations take precedence over any default settings.
CMock and Ceedling settings are divided into internal configuration, and defaults. The internal config section contains the cmock plugin and include settings, the vendor and plugin paths, etc. as we felt it was unlikely that the user would intend to replace these in
project.yml
but rather add to them.New config loading procedure:
project.yml
with Ceedling and CMock internal settings, then merge withplugins
-->config
DEFAULT_CEEDLING_CONFIG
withDEFAULT_TOOLS_*
, CMock and Unity defaults, and plugindefaults
-->defaults
config
withdefaults
New priority:
config
:project.yml
plugin
settingsdefaults
:defaults
DEFAULT_CEEDLING_CONFIG
,DEFAULT_TOOLS_*
,All
config
parameters take precedence over and replace alldefaults
, i.e. are not deep_merged with them. This allows plugin to have the choice to add to theconfig
as if specified by the user inproject.yml
, or add to thedefaults
but still have those values be able to be replaced by the user or another plugin.Impact
project.yml
orplugin
config will replace those inDEFAULT_CEEDLING_CONFIG
,DEFAULT_TOOLS_*
etc instead of being merged with them.defaults
will be merged with (if mergeable) or replace (if not) Ceedling and other plugin defaults instead of being ignored in favour of the Ceedling or other plugin defaults