Skip to content

Commit

Permalink
Only remove null values if it is a boolean field
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanCoding committed Oct 3, 2023
1 parent 165471a commit 45d6f49
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions awx_collection/plugins/module_utils/controller_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -980,12 +980,14 @@ def update_if_needed(self, existing_item, new_item, on_update=None, auto_exit=Tr
def create_or_update_if_needed(
self, existing_item, new_item, endpoint=None, item_type='unknown', on_create=None, on_update=None, auto_exit=True, associations=None
):
# Remove null values - this assumes there are no nullable fields with non-null defaults
# the None value is used to indicate not-provided by Ansible and argparse
# Remove boolean values of certain specific types
# this is needed so that boolean fields will not get a false value when not provided
for key in list(new_item.keys()):
if new_item[key] is None:
new_item.pop(key)
if key in self.argument_spec:
param_spec = self.argument_spec[key]
if 'type' in param_spec and param_spec['type'] == 'bool':
if new_item[key] is None:
new_item.pop(key)

if existing_item:
return self.update_if_needed(existing_item, new_item, on_update=on_update, auto_exit=auto_exit, associations=associations)
Expand Down

0 comments on commit 45d6f49

Please sign in to comment.