Skip to content

Commit

Permalink
Fix missing casts for firewall results
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Jan 14, 2024
1 parent feb3ced commit f06d1ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
12 changes: 7 additions & 5 deletions plugins/modules/firewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def _prepare_result(self):

def _prepare_result_rule(self, rule: FirewallRule):
return {
"direction": rule.direction,
"direction": to_native(rule.direction),
"protocol": to_native(rule.protocol),
"port": to_native(rule.port) if rule.port is not None else None,
"source_ips": [to_native(cidr) for cidr in rule.source_ips],
Expand All @@ -251,15 +251,17 @@ def _prepare_result_rule(self, rule: FirewallRule):

def _prepare_result_applied_to(self, resource: FirewallResource):
result = {
"type": resource.type,
"type": to_native(resource.type),
"server": to_native(resource.server.id) if resource.server is not None else None,
"label_selector": resource.label_selector.selector if resource.label_selector is not None else None,
"label_selector": to_native(resource.label_selector.selector)
if resource.label_selector is not None
else None,
}
if resource.applied_to_resources is not None:
result["applied_to_resources"] = [
{
"type": item.type,
"server": item.server.id if item.server is not None else None,
"type": to_native(item.type),
"server": to_native(item.server.id) if item.server is not None else None,
}
for item in resource.applied_to_resources
]
Expand Down
12 changes: 7 additions & 5 deletions plugins/modules/firewall_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def _prepare_result(self):
def _prepare_result_rule(self, rule: FirewallRule):
return {
"description": to_native(rule.description) if rule.description is not None else None,
"direction": rule.direction,
"direction": to_native(rule.direction),
"protocol": to_native(rule.protocol),
"port": to_native(rule.port) if rule.port is not None else None,
"source_ips": [to_native(cidr) for cidr in rule.source_ips],
Expand All @@ -189,15 +189,17 @@ def _prepare_result_rule(self, rule: FirewallRule):

def _prepare_result_applied_to(self, resource: FirewallResource):
result = {
"type": resource.type,
"type": to_native(resource.type),
"server": to_native(resource.server.id) if resource.server is not None else None,
"label_selector": resource.label_selector.selector if resource.label_selector is not None else None,
"label_selector": to_native(resource.label_selector.selector)
if resource.label_selector is not None
else None,
}
if resource.applied_to_resources is not None:
result["applied_to_resources"] = [
{
"type": item.type,
"server": item.server.id if item.server is not None else None,
"type": to_native(item.type),
"server": to_native(item.server.id) if item.server is not None else None,
}
for item in resource.applied_to_resources
]
Expand Down

0 comments on commit f06d1ce

Please sign in to comment.