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

Bump required octodns >= 1.5, address pending deprecations #114

Open
wants to merge 1 commit into
base: main
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
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## v1.0.0 - 2024-??-?? - ???

Noteworthy Changes:

* Complete removal of SPF record support, records should be transitioned to TXT
values before updating to this version.

Changes:

* Address pending octoDNS 2.x deprecations, require minimum of 1.5.x

## v0.0.7 - 2024-08-20 - DS always come second

* Create DS records after their sibling NS records to appease Cloudflare's
Expand Down
26 changes: 11 additions & 15 deletions octodns_cloudflare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from octodns import __VERSION__ as octodns_version
from octodns.idna import IdnaDict
from octodns.provider import ProviderException, SupportsException
from octodns.provider import ProviderException
from octodns.provider.base import BaseProvider
from octodns.record import Create, Record, Update

Expand Down Expand Up @@ -68,7 +68,6 @@ class CloudflareProvider(BaseProvider):
'PTR',
'SSHFP',
'SRV',
'SPF',
'TLSA',
'TXT',
)
Expand Down Expand Up @@ -511,28 +510,28 @@ def _record_for(self, zone, name, _type, records, lenient):
auto_ttl = records[0]['ttl'] == 1
if proxied:
self.log.debug('_record_for: proxied=True, auto-ttl=True')
record._octodns['cloudflare'] = {'proxied': True, 'auto-ttl': True}
record.octodns['cloudflare'] = {'proxied': True, 'auto-ttl': True}
elif auto_ttl:
# auto-ttl can still be set on any record type, signaled by a ttl=1,
# even if proxied is false.
self.log.debug('_record_for: auto-ttl=True')
record._octodns['cloudflare'] = {'auto-ttl': True}
record.octodns['cloudflare'] = {'auto-ttl': True}

# update record comment
if records[0].get('comment'):
try:
record._octodns['cloudflare']['comment'] = records[0]['comment']
record.octodns['cloudflare']['comment'] = records[0]['comment']
except KeyError:
record._octodns['cloudflare'] = {
record.octodns['cloudflare'] = {
'comment': records[0]['comment']
}

# update record tags
if records[0].get('tags'):
try:
record._octodns['cloudflare']['tags'] = records[0]['tags']
record.octodns['cloudflare']['tags'] = records[0]['tags']
except KeyError:
record._octodns['cloudflare'] = {'tags': records[0]['tags']}
record.octodns['cloudflare'] = {'tags': records[0]['tags']}

return record

Expand Down Expand Up @@ -607,9 +606,6 @@ def populate(self, zone, target=False, lenient=False):
return exists

def _include_change(self, change):
if isinstance(change, Create) and change.new._type == 'SPF':
msg = f'{self.id}: creating new SPF records not supported, use TXT instead'
raise SupportsException(msg)

if isinstance(change, Update):
new = change.new
Expand Down Expand Up @@ -853,7 +849,7 @@ def _contents_for_URLFWD(self, record):
}

def _record_is_proxied(self, record):
return not self.cdn and record._octodns.get('cloudflare', {}).get(
return not self.cdn and record.octodns.get('cloudflare', {}).get(
'proxied', False
)

Expand All @@ -862,16 +858,16 @@ def _record_is_just_auto_ttl(self, record):
return (
not self._record_is_proxied(record)
and not self.cdn
and record._octodns.get('cloudflare', {}).get('auto-ttl', False)
and record.octodns.get('cloudflare', {}).get('auto-ttl', False)
)

def _record_comment(self, record):
'Returns record comment'
return record._octodns.get('cloudflare', {}).get('comment', '')
return record.octodns.get('cloudflare', {}).get('comment', '')

def _record_tags(self, record):
'Returns nonduplicate record tags'
return set(record._octodns.get('cloudflare', {}).get('tags', []))
return set(record.octodns.get('cloudflare', {}).get('tags', []))

def _gen_data(self, record):
name = record.fqdn[:-1]
Expand Down
2 changes: 1 addition & 1 deletion octodns_cloudflare/processor/proxycname.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def process_source_and_target_zones(self, desired, existing, target):
# Check the record is NOT Cloudflare proxied OR is a non Cloudflare proxyable record type
# https://developers.cloudflare.com/dns/manage-dns-records/reference/proxied-dns-records/#record-types
# NOTE: Inclusion of ALIAS as this is generally a CNAME equivalent that can be used at the root
if not record._octodns.get('cloudflare', {}).get(
if not record.octodns.get('cloudflare', {}).get(
'proxied', False
) or record._type not in ['ALIAS', 'A', 'AAAA', 'CNAME']:
# Not interested in this record.
Expand Down
2 changes: 1 addition & 1 deletion octodns_cloudflare/processor/ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def process_source_zone(self, zone, *args, **kwargs):
for record in zone.records:
if record.ttl == self.ttl:
record = record.copy()
record._octodns['cloudflare'] = {
record.octodns['cloudflare'] = {
'proxied': True,
'auto-ttl': True,
}
Expand Down
2 changes: 0 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,5 @@ sections="FUTURE,STDLIB,THIRDPARTY,OCTODNS,FIRSTPARTY,LOCALFOLDER"
[tool.pytest.ini_options]
filterwarnings = [
'error',
# TODO: remove once octodns 2.0 has been released
'ignore:.*DEPRECATED.*2.0',
]
pythonpath = "."
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def version():
),
'test': tests_require,
},
install_requires=('octodns>=0.9.20', 'requests>=2.27.0'),
install_requires=('octodns>=1.5.0', 'requests>=2.27.0'),
license='MIT',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
15 changes: 1 addition & 14 deletions tests/config/unit.tests.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
---
? ''
: - geo:
AF:
- 2.2.3.4
- 2.2.3.5
AS-JP:
- 3.2.3.4
- 3.2.3.5
NA-US:
- 4.2.3.4
- 4.2.3.5
NA-US-CA:
- 5.2.3.4
- 5.2.3.5
ttl: 300
: - ttl: 300
type: A
values:
- 1.2.3.4
Expand Down
Loading
Loading