Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-0.10] Fix apply to cope better with missing last_applied entries #352

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions openshift/dynamic/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ def get_delta(last_applied, actual, desired, position=None):
if actual_value is None:
patch[k] = desired_value
elif isinstance(desired_value, dict):
p = get_delta(last_applied.get(k), actual_value, desired_value, this_position)
p = get_delta(last_applied.get(k, {}), actual_value, desired_value, this_position)
if p:
patch[k] = p
elif isinstance(desired_value, list):
p = list_merge(last_applied.get(k), actual_value, desired_value, this_position)
p = list_merge(last_applied.get(k, []), actual_value, desired_value, this_position)
if p:
patch[k] = [item for item in p if item]
elif actual_value != desired_value:
Expand Down
31 changes: 31 additions & 0 deletions test/unit/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,37 @@
}
}
}
),
dict(
last_applied = {
'kind': 'MadeUp',
'toplevel': {
'original': 'entry'
}
},
actual = {
'kind': 'MadeUp',
'toplevel': {
'original': 'entry',
'another': {
'nested': {
'entry': 'value'
}
}
}
},
desired = {
'kind': 'MadeUp',
'toplevel': {
'original': 'entry',
'another': {
'nested': {
'entry': 'value'
}
}
}
},
expected = {}
)
]

Expand Down