Skip to content

Commit

Permalink
Fix bug to be idempotent in case of multiple same type records
Browse files Browse the repository at this point in the history
For example, domains often have multiple MX or TXT records for the root part of the domain. To have the outcome of the module be idempotent also sort on content of the record.
  • Loading branch information
rlenferink committed Mar 8, 2023
1 parent 1701865 commit 397f7bb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/transip_dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def main():
existing_records = fetch_dns_records(request_headers, domain)

# Sort the records before comparing, order doesn't matter for DNS records
existing_records.sort(key=lambda x: (x['name'], x['type']), reverse=False)
records.sort(key=lambda x: (x['name'], x['type']), reverse=False)
existing_records.sort(key=lambda x: (x['name'], x['type'], x['content']), reverse=False)
records.sort(key=lambda x: (x['name'], x['type'], x['content']), reverse=False)

# Only perform an update if the DNS entries differ
if existing_records != records:
Expand Down

0 comments on commit 397f7bb

Please sign in to comment.