From 8ca7070186c5609b4abde2c4d7ecb0fa6204c9ef Mon Sep 17 00:00:00 2001 From: Brian E Clow Date: Fri, 23 Jul 2021 15:03:51 -0700 Subject: [PATCH] Formatting, lingering pr comments, fixing resulting errors --- octodns/provider/cloudflare.py | 25 ++++++++++++----------- octodns/record/__init__.py | 2 -- tests/test_octodns_provider_cloudflare.py | 6 +++--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/octodns/provider/cloudflare.py b/octodns/provider/cloudflare.py index c79b5ce..01710b6 100644 --- a/octodns/provider/cloudflare.py +++ b/octodns/provider/cloudflare.py @@ -299,7 +299,7 @@ class CloudflareProvider(BaseProvider): }) return { 'type': _type, - 'ttl': 3600, # ttl does not exist for this type, forcing a setting + 'ttl': 300, # ttl does not exist for this type, forcing a setting 'values': values } @@ -376,10 +376,10 @@ class CloudflareProvider(BaseProvider): path = parsed_uri.path _type = 'URLFWD' # assumption, actions will always contain 1 action - values = record['actions'][0]['value'] - values['path'] = path + _values = record['actions'][0]['value'] + _values['path'] = path # no ttl set by pagerule, creating one - values['ttl'] = 3600 + _values['ttl'] = 300 values[name][_type].append(_values) # the dns_records branch # elif 'name' in record: @@ -618,9 +618,10 @@ class CloudflareProvider(BaseProvider): uri = data['targets'][0]['constraint']['value'] uri = '//' + uri if not uri.startswith('http') else uri parsed_uri = urlsplit(uri) - return '{name} {path} {url} {status_code}'.format(name=parsed_uri.netloc, - path=parsed_uri.path, - **data['actions'][0]['value']) + return '{name} {path} {url} {status_code}' \ + .format(name=parsed_uri.netloc, + path=parsed_uri.path, + **data['actions'][0]['value']) return data['content'] def _apply_Create(self, change): @@ -649,11 +650,11 @@ class CloudflareProvider(BaseProvider): name = zone.hostname_from_fqdn(parsed_uri.netloc) path = parsed_uri.path # assumption, actions will always contain 1 action - values = record['actions'][0]['value'] - values['path'] = path - values['ttl'] = 3600 - values['type'] = 'URLFWD' - record.update(values) + _values = record['actions'][0]['value'] + _values['path'] = path + _values['ttl'] = 300 + _values['type'] = 'URLFWD' + record.update(_values) else: name = zone.hostname_from_fqdn(record['name']) # Use the _record_for so that we include all of standard diff --git a/octodns/record/__init__.py b/octodns/record/__init__.py index 5acffab..7714b27 100644 --- a/octodns/record/__init__.py +++ b/octodns/record/__init__.py @@ -1470,8 +1470,6 @@ class TxtRecord(_ChunkedValuesMixin, Record): class UrlfwdValue(EqualityTupleMixin): - # TODO: should have defaults for path, code, masking, and query - VALID_CODES = (301, 302) VALID_MASKS = (0, 1, 2) VALID_QUERY = (0, 1) diff --git a/tests/test_octodns_provider_cloudflare.py b/tests/test_octodns_provider_cloudflare.py index c2addf0..2cc11cb 100644 --- a/tests/test_octodns_provider_cloudflare.py +++ b/tests/test_octodns_provider_cloudflare.py @@ -411,7 +411,7 @@ class TestCloudflareProvider(TestCase): 'value': '3.2.3.4' })) wanted.add_record(Record.new(wanted, 'urlfwd', { - 'ttl': 3600, + 'ttl': 300, 'type': 'URLFWD', 'value': { 'path': '/*', # path change @@ -689,7 +689,7 @@ class TestCloudflareProvider(TestCase): 'values': ['ns1.foo.bar.', 'ns2.foo.bar.'], }) exstingurlfwd = Record.new(zone, 'urlfwd1', { - 'ttl': 3600, + 'ttl': 300, 'type': 'URLFWD', 'values': [ { @@ -715,7 +715,7 @@ class TestCloudflareProvider(TestCase): 'value': 'ns2.foo.bar.', }) newurlfwd = Record.new(zone, 'urlfwd1', { - 'ttl': 3600, + 'ttl': 300, 'type': 'URLFWD', 'value': { 'path': '/',