diff --git octodns_powerdns/__init__.py octodns_powerdns/__init__.py index 240a113..0fd8050 100644 --- octodns_powerdns/__init__.py +++ octodns_powerdns/__init__.py @@ -14,7 +14,15 @@ from octodns.record import Record from .record import PowerDnsLuaRecord -__VERSION__ = '0.0.5' +try: + from packaging.version import parse as parse_version +except ImportError: + + def parse_version(v): + return tuple(map(int, (v.split(".")))) + + +__VERSION__ = '0.0.6' def _escape_unescaped_semicolons(value): @@ -177,14 +185,24 @@ class PowerDnsBaseProvider(BaseProvider): (key_tag, algorithm, digest_type, digest) = record['content'].split( ' ', 3 ) - values.append( - { - 'key_tag': key_tag, - 'algorithm': algorithm, - 'digest_type': digest_type, - 'digest': digest, - } - ) + if parse_version(octodns_version) >= parse_version("1.1.2"): + values.append( + { + 'key_tag': key_tag, + 'algorithm': algorithm, + 'digest_type': digest_type, + 'digest': digest, + } + ) + else: + values.append( + { + 'flags': key_tag, + 'protocol': algorithm, + 'algorithm': digest_type, + 'public_key': digest, + } + ) return {'type': rrset['type'], 'values': values, 'ttl': rrset['ttl']} def _data_for_CAA(self, rrset): @@ -486,7 +504,9 @@ class PowerDnsBaseProvider(BaseProvider): def _records_for_DS(self, record): return [ { - 'content': f'{v.key_tag} {v.algorithm} {v.digest_type} {v.digest}', + 'content': f'{v.key_tag} {v.algorithm} {v.digest_type} {v.digest}' + if parse_version(octodns_version) >= parse_version("1.1.2") + else f'{v.flags} {v.protocol} {v.algorithm} {v.public_key}', 'disabled': False, } for v in record.values