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

Remove empty values after param validation #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ def populate_facts(self, connection, ansible_facts, data=None):
objs.append(obj)
facts = {}
if objs:
facts['interfaces'] = []
params = utils.validate_config(self.argument_spec, {'config': objs})
facts['interfaces'] = params['config']
for cfg in params['config']:
facts['interfaces'].append(utils.remove_empties(cfg))

ansible_facts['ansible_network_resources'].update(facts)
return ansible_facts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ class {{ resource|capitalize }}Facts(object):
objs.append(obj)
facts = {}
if objs:
facts['{{ resource }}'] = []
Copy link
Member

Choose a reason for hiding this comment

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

Quick question: Would this break for facts with are inherently not a list of items (e.g., lacp)?

Copy link
Member Author

Choose a reason for hiding this comment

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

By default, the value stored for the fact is a list of dict. In case the fact is not a list item it is converted to list of dict and stored in facts as per the current logic. Adding this line won't change existing behavior.

params = utils.validate_config(self.argument_spec, {'config': objs})
facts['{{ resource }}'] = params['config']
for cfg in params['config']:
facts['{{ resource }}'].append(utils.remove_empties(cfg))

ansible_facts['ansible_network_resources'].update(facts)
return ansible_facts
Expand Down