Restructure the setup config load order
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:
- Merge
project.ymlwithDEFAULT_CEEDLING_CONFIG - Populate with
DEFAULT_TOOLS_*,CMock, andUnitysettings. - Merge with
pluginsettings. - Merge with plugin
defaults.
Resulting priority order (highest first):
project.ymlDEFAULT_CEEDLING_CONFIGDEFAULT_TOOLS_*,CMock, andUnitypluginsettings- plugin
defaults
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:
- Populate
project.ymlwith Ceedling and CMock internal settings, then merge withplugins-->config - Merge
DEFAULT_CEEDLING_CONFIGwithDEFAULT_TOOLS_*, CMock and Unity defaults, and plugindefaults-->defaults - Populate
configwithdefaults
New priority:
config:
project.yml- CMock and Ceedling internal configuration
pluginsettings
defaults:
- plugin
defaults DEFAULT_CEEDLING_CONFIG,DEFAULT_TOOLS_*,- CMock and Unity defaults
All config parameters take precedence over and replace all defaults, i.e. are not deep_merged with them. This allows plugin to have the choice to add to the config as if specified by the user in project.yml, or add to the defaults but still have those values be able to be replaced by the user or another plugin.
Impact
- Settings provided in
project.ymlorpluginconfig will replace those inDEFAULT_CEEDLING_CONFIG,DEFAULT_TOOLS_*etc instead of being merged with them.- Most of the defaults are either atoms that can't be merged, or empty lists anyway. Those that were not have been moved to 'internal configuration' which is merged.
- Settings provided in plugin
defaultswill 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