Skip to content

Commit ebd435a

Browse files
DingMeng-Siemensjan-kiszka
authored andcommitted
fix: deepcopy config and return instead of returning a reference.
Dump plugin(and maybe other plugin) will get_config and delete the "includes" key, that will delete the key from the original config because get_config did not deepcopy the config. [Felix: state in API doc that get_config returns a copy] Signed-off-by: Ding Meng <[email protected]> Signed-off-by: Felix Moessbauer <[email protected]> Signed-off-by: Jan Kiszka <[email protected]>
1 parent f44176f commit ebd435a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

kas/config.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import os
2727
import json
28+
import copy
2829
from pathlib import Path
2930
from .repos import Repo
3031
from .includehandler import IncludeHandler
@@ -80,11 +81,14 @@ def find_missing_repos(self, repo_paths={}):
8081

8182
return missing_repo_names
8283

83-
def get_config(self):
84+
def get_config(self, remove_includes=False):
8485
"""
85-
Returns the config dict.
86+
Returns a copy of the config dict
8687
"""
87-
return self._config
88+
config = copy.deepcopy(self._config)
89+
if remove_includes and 'includes' in config['header']:
90+
del config['header']['includes']
91+
return config
8892

8993
def get_repos_config(self):
9094
"""

0 commit comments

Comments
 (0)