Merge pull request #17 from tkloda/iac

fixed comparison issue in other modules
This commit is contained in:
tkloda
2026-03-27 14:31:24 +01:00
committed by GitHub
3 changed files with 21 additions and 7 deletions
+3 -2
View File
@@ -318,8 +318,9 @@ def policy_needs_update(current, params):
"""Check if policy needs to be updated."""
if params.get('name') is not None and current.get('name') != params['name']:
return True
if params.get('description') is not None and current.get('description') != params['description']:
return True
if params.get('description') is not None:
if (current.get('description') or '') != (params['description'] or ''):
return True
if params.get('enabled') is not None and current.get('enabled') != params['enabled']:
return True
if params.get('source_posture_checks') is not None:
+12 -4
View File
@@ -224,15 +224,23 @@ def find_posture_check_by_name(api, name):
return None
def normalize_checks(checks):
"""Normalize checks dict for comparison, removing None/null entries."""
if not checks:
return {}
return {k: v for k, v in checks.items() if v is not None}
def posture_check_needs_update(current, params):
"""Check if posture check needs to be updated."""
if params.get('name') is not None and current.get('name') != params['name']:
return True
if params.get('description') is not None and current.get('description') != params['description']:
return True
# For checks, always update if provided to ensure they match exactly
if params.get('description') is not None:
if (current.get('description') or '') != (params['description'] or ''):
return True
if params.get('checks') is not None:
return True
if normalize_checks(current.get('checks')) != normalize_checks(params['checks']):
return True
return False
+6 -1
View File
@@ -197,10 +197,15 @@ def find_route_by_network_id(api, network_id):
def route_needs_update(current, params):
"""Check if route needs to be updated."""
check_fields = ['network', 'description', 'metric', 'masquerade', 'enabled', 'keep_route']
check_fields = ['network', 'metric', 'masquerade', 'enabled', 'keep_route']
for field in check_fields:
if params.get(field) is not None and current.get(field) != params[field]:
return True
# Check description (normalize None to '')
if params.get('description') is not None:
if (current.get('description') or '') != (params['description'] or ''):
return True
# Check peer
if params.get('peer_id') is not None and current.get('peer') != params['peer_id']: