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

report smaller diffs by dropping null values. #1398

Merged
merged 1 commit into from
May 2, 2022
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
2 changes: 2 additions & 0 deletions changelogs/fragments/smaller-diffs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- all modules - report smaller diffs by dropping ``null`` values. This should result in not showing fields that were unset to begin with, and mark fields that were explicitly removed as "deleted" instead of "replaced by ``null``"
12 changes: 10 additions & 2 deletions plugins/module_utils/foreman_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,10 +946,18 @@ def auto_lookup_nested_entities(self):
item[nested_key] = self._lookup_entity(item[nested_key], nested_spec)

def record_before(self, resource, entity):
self._before[resource].append(entity)
if isinstance(entity, dict):
to_record = _recursive_dict_without_none(entity)
else:
to_record = entity
self._before[resource].append(to_record)

def record_after(self, resource, entity):
self._after[resource].append(entity)
if isinstance(entity, dict):
to_record = _recursive_dict_without_none(entity)
else:
to_record = entity
self._after[resource].append(to_record)

def record_after_full(self, resource, entity):
self._after_full[resource].append(entity)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_playbooks/activation_key.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
expected_change: true
expected_diff: true
expected_diff_before: "Test_Organization_Test_Product_Test_Repository.*false"
expected_diff_after: "Test_Organization_Test_Product_Test_Repository.*null"
expected_diff_after: "content_overrides.*{}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was actually depending on that wrong behavior ;)

- name: update AK with content overrides set to default again, no change
include_tasks: tasks/activation_key.yml
vars:
Expand Down