Skip to content

Commit

Permalink
use max header version number when merging configs
Browse files Browse the repository at this point in the history
The header version cannot be merged in-order, as otherwise an include
file with a lower version defines the version of the merged config,
which might not be valid (e.g. if properties are used that are not
available in that version).

This aspect was irrelevant prior to introducing the dump plugin, as the
data is not used within kas. However, the dump plugin needs to use the
max header version as otherwise the generated config might not be valid.

Fixes: 5b3e238 ("add plugin to dump flattened config")
Signed-off-by: Felix Moessbauer <[email protected]>
Signed-off-by: Jan Kiszka <[email protected]>
  • Loading branch information
fmoessbauer authored and jan-kiszka committed Dec 21, 2024
1 parent f38bc1e commit eed99a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/userguide/project-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ be overwritten by the current file. While merging all the dictionaries are
merged recursively while preserving the order in which the entries are added to
the dictionary. This means that ``local_conf_header`` entries are added to the
``local.conf`` file in the same order in which they are defined in the
different include files.
different include files. The ``header.version`` property is always set to the
highest version number found in the config files.

Including configuration files via the command line
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
4 changes: 4 additions & 0 deletions kas/includehandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,4 +306,8 @@ def _internal_dict_merge(dest, upd):

config = functools.reduce(_internal_dict_merge,
map(lambda x: x[1], configs))
# the merged config must have the highest (used) version number
header_version = max([int(cfg['header']['version'])
for _, cfg in configs])
config['header']['version'] = header_version
return config, missing_repos

0 comments on commit eed99a1

Please sign in to comment.