Skip to content

Commit

Permalink
fix: correct a mistake in values file merging for gitops validation
Browse files Browse the repository at this point in the history
The code was crashing when merging 2 values files with a conflicting
type where one was a dict.
  • Loading branch information
yannrouillard committed Aug 14, 2024
1 parent a1c4227 commit 0e64846
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kp_pre_commit_hooks/gitops-values-validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ def deep_merge(*sources) -> dict:
result = {}
for dictionary in sources:
for key, value in dictionary.items():
if isinstance(value, dict):
result[key] = deep_merge(result.setdefault(key, {}), value)
current_value = result.get(key, None)
if isinstance(value, dict) and isinstance(current_value, dict):
result[key] = deep_merge(current_value, value)
else:
result[key] = value
return result
Expand Down

0 comments on commit 0e64846

Please sign in to comment.