Browse Source

Formatting, lingering pr comments, fixing resulting errors

pull/722/head
Brian E Clow 4 years ago
parent
commit
8ca7070186
3 changed files with 16 additions and 17 deletions
  1. +13
    -12
      octodns/provider/cloudflare.py
  2. +0
    -2
      octodns/record/__init__.py
  3. +3
    -3
      tests/test_octodns_provider_cloudflare.py

+ 13
- 12
octodns/provider/cloudflare.py View File

@ -299,7 +299,7 @@ class CloudflareProvider(BaseProvider):
}) })
return { return {
'type': _type, '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 'values': values
} }
@ -376,10 +376,10 @@ class CloudflareProvider(BaseProvider):
path = parsed_uri.path path = parsed_uri.path
_type = 'URLFWD' _type = 'URLFWD'
# assumption, actions will always contain 1 action # 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 # no ttl set by pagerule, creating one
values['ttl'] = 3600
_values['ttl'] = 300
values[name][_type].append(_values) values[name][_type].append(_values)
# the dns_records branch # the dns_records branch
# elif 'name' in record: # elif 'name' in record:
@ -618,9 +618,10 @@ class CloudflareProvider(BaseProvider):
uri = data['targets'][0]['constraint']['value'] uri = data['targets'][0]['constraint']['value']
uri = '//' + uri if not uri.startswith('http') else uri uri = '//' + uri if not uri.startswith('http') else uri
parsed_uri = urlsplit(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'] return data['content']
def _apply_Create(self, change): def _apply_Create(self, change):
@ -649,11 +650,11 @@ class CloudflareProvider(BaseProvider):
name = zone.hostname_from_fqdn(parsed_uri.netloc) name = zone.hostname_from_fqdn(parsed_uri.netloc)
path = parsed_uri.path path = parsed_uri.path
# assumption, actions will always contain 1 action # 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: else:
name = zone.hostname_from_fqdn(record['name']) name = zone.hostname_from_fqdn(record['name'])
# Use the _record_for so that we include all of standard # Use the _record_for so that we include all of standard


+ 0
- 2
octodns/record/__init__.py View File

@ -1470,8 +1470,6 @@ class TxtRecord(_ChunkedValuesMixin, Record):
class UrlfwdValue(EqualityTupleMixin): class UrlfwdValue(EqualityTupleMixin):
# TODO: should have defaults for path, code, masking, and query
VALID_CODES = (301, 302) VALID_CODES = (301, 302)
VALID_MASKS = (0, 1, 2) VALID_MASKS = (0, 1, 2)
VALID_QUERY = (0, 1) VALID_QUERY = (0, 1)


+ 3
- 3
tests/test_octodns_provider_cloudflare.py View File

@ -411,7 +411,7 @@ class TestCloudflareProvider(TestCase):
'value': '3.2.3.4' 'value': '3.2.3.4'
})) }))
wanted.add_record(Record.new(wanted, 'urlfwd', { wanted.add_record(Record.new(wanted, 'urlfwd', {
'ttl': 3600,
'ttl': 300,
'type': 'URLFWD', 'type': 'URLFWD',
'value': { 'value': {
'path': '/*', # path change 'path': '/*', # path change
@ -689,7 +689,7 @@ class TestCloudflareProvider(TestCase):
'values': ['ns1.foo.bar.', 'ns2.foo.bar.'], 'values': ['ns1.foo.bar.', 'ns2.foo.bar.'],
}) })
exstingurlfwd = Record.new(zone, 'urlfwd1', { exstingurlfwd = Record.new(zone, 'urlfwd1', {
'ttl': 3600,
'ttl': 300,
'type': 'URLFWD', 'type': 'URLFWD',
'values': [ 'values': [
{ {
@ -715,7 +715,7 @@ class TestCloudflareProvider(TestCase):
'value': 'ns2.foo.bar.', 'value': 'ns2.foo.bar.',
}) })
newurlfwd = Record.new(zone, 'urlfwd1', { newurlfwd = Record.new(zone, 'urlfwd1', {
'ttl': 3600,
'ttl': 300,
'type': 'URLFWD', 'type': 'URLFWD',
'value': { 'value': {
'path': '/', 'path': '/',


Loading…
Cancel
Save