mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Apply suggestions from code review
Thank you, Ross Co-authored-by: Ross McFarland <rwmcfa1@gmail.com>
This commit is contained in:
@@ -373,13 +373,13 @@ class CloudflareProvider(BaseProvider):
|
|||||||
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)
|
||||||
name = zone.hostname_from_fqdn(parsed_uri.netloc)
|
name = zone.hostname_from_fqdn(parsed_uri.netloc)
|
||||||
_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 = record['actions'][0]['value']
|
||||||
_values['path'] = _path
|
values['path'] = path
|
||||||
# no ttl set by pagerule, creating one
|
# no ttl set by pagerule, creating one
|
||||||
_values['ttl'] = 3600
|
values['ttl'] = 3600
|
||||||
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:
|
||||||
@@ -589,10 +589,7 @@ class CloudflareProvider(BaseProvider):
|
|||||||
# content as things are currently implemented so we need to handle
|
# content as things are currently implemented so we need to handle
|
||||||
# those explicitly and create unique/hashable strings for them.
|
# those explicitly and create unique/hashable strings for them.
|
||||||
# AND... for URLFWD/Redirects additional adventures are created.
|
# AND... for URLFWD/Redirects additional adventures are created.
|
||||||
if 'targets' in data:
|
_type = data.get('type', 'URLFWD')
|
||||||
_type = 'URLFWD'
|
|
||||||
else:
|
|
||||||
_type = data['type']
|
|
||||||
if _type == 'MX':
|
if _type == 'MX':
|
||||||
return '{priority} {content}'.format(**data)
|
return '{priority} {content}'.format(**data)
|
||||||
elif _type == 'CAA':
|
elif _type == 'CAA':
|
||||||
@@ -621,15 +618,9 @@ 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)
|
||||||
ret = {}
|
return '{name} {path} {url} {status_code}'.format(name=parsed_uri.netloc,
|
||||||
ret.update(data['actions'][0]['value'])
|
path=parsed_uri.path,
|
||||||
ret.update({'name': parsed_uri.netloc, 'path': parsed_uri.path})
|
**data['actions'][0]['value'])
|
||||||
urlfwd = (
|
|
||||||
'{name}',
|
|
||||||
'{path}',
|
|
||||||
'{url}',
|
|
||||||
'{status_code}')
|
|
||||||
return ' '.join(urlfwd).format(**ret)
|
|
||||||
return data['content']
|
return data['content']
|
||||||
|
|
||||||
def _apply_Create(self, change):
|
def _apply_Create(self, change):
|
||||||
@@ -656,13 +647,13 @@ class CloudflareProvider(BaseProvider):
|
|||||||
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)
|
||||||
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 = record['actions'][0]['value']
|
||||||
_values['path'] = _path
|
values['path'] = path
|
||||||
_values['ttl'] = 3600
|
values['ttl'] = 3600
|
||||||
_values['type'] = 'URLFWD'
|
values['type'] = 'URLFWD'
|
||||||
record.update(_values)
|
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
|
||||||
|
Reference in New Issue
Block a user