mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Deny up-flag support in BaseProvider
This commit is contained in:
@@ -457,6 +457,7 @@ class AzureProvider(BaseProvider):
|
||||
'''
|
||||
SUPPORTS_GEO = False
|
||||
SUPPORTS_DYNAMIC = True
|
||||
SUPPORTS_POOL_VALUE_UP = True
|
||||
SUPPORTS_MUTLIVALUE_PTR = True
|
||||
SUPPORTS = set(('A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SRV',
|
||||
'TXT'))
|
||||
|
||||
@@ -57,14 +57,28 @@ class BaseProvider(BaseSource):
|
||||
fallback = 'omitting record'
|
||||
self.supports_warn_or_except(msg, fallback)
|
||||
desired.remove_record(record)
|
||||
elif getattr(record, 'dynamic', False) and \
|
||||
not self.SUPPORTS_DYNAMIC:
|
||||
msg = f'dynamic records not supported for {record.fqdn}'
|
||||
fallback = 'falling back to simple record'
|
||||
self.supports_warn_or_except(msg, fallback)
|
||||
record = record.copy()
|
||||
record.dynamic = None
|
||||
desired.add_record(record, replace=True)
|
||||
elif getattr(record, 'dynamic', False):
|
||||
if self.SUPPORTS_DYNAMIC:
|
||||
pools = record.dynamic.pools.values()
|
||||
values = [p.data['values'] for p in pools]
|
||||
if any(isinstance(v['up'], bool) for v in values) and not \
|
||||
self.SUPPORTS_POOL_VALUE_UP:
|
||||
msg = f'"up" flag used in {record.fqdn} is not ' \
|
||||
f'supported'
|
||||
fallback = 'falling back to using healthchecks'
|
||||
self.supports_warn_or_except(msg, fallback)
|
||||
record = record.copy()
|
||||
for pool in record.dynamic.pools.values():
|
||||
for value in pool.data['values']:
|
||||
value['up'] = None
|
||||
desired.add_record(record, replace=True)
|
||||
else:
|
||||
msg = f'dynamic records not supported for {record.fqdn}'
|
||||
fallback = 'falling back to simple record'
|
||||
self.supports_warn_or_except(msg, fallback)
|
||||
record = record.copy()
|
||||
record.dynamic = None
|
||||
desired.add_record(record, replace=True)
|
||||
elif record._type == 'PTR' and len(record.values) > 1 and \
|
||||
not self.SUPPORTS_MUTLIVALUE_PTR:
|
||||
# replace with a single-value copy
|
||||
|
||||
@@ -306,6 +306,7 @@ class Ns1Provider(BaseProvider):
|
||||
'''
|
||||
SUPPORTS_GEO = True
|
||||
SUPPORTS_DYNAMIC = True
|
||||
SUPPORTS_POOL_VALUE_UP = True
|
||||
SUPPORTS_MUTLIVALUE_PTR = True
|
||||
SUPPORTS = set(('A', 'AAAA', 'ALIAS', 'CAA', 'CNAME', 'MX', 'NAPTR',
|
||||
'NS', 'PTR', 'SPF', 'SRV', 'TXT', 'URLFWD'))
|
||||
|
||||
@@ -941,16 +941,6 @@ class Route53Provider(BaseProvider):
|
||||
rule.data['geos'] = filtered_geos
|
||||
rules.append(rule)
|
||||
|
||||
# check for use of 'up' flag and warn/except if used
|
||||
for name, pool in dynamic.pools.items():
|
||||
for value in pool.data['values']:
|
||||
if value['up'] is not None:
|
||||
msg = f'"up" flag is not supported for "{name}"' \
|
||||
f' pool in {record.fqdn}'
|
||||
fallback = 'ignoring it, octodns-sync command ' \
|
||||
'will keep showing changes'
|
||||
self.supports_warn_or_except(msg, fallback)
|
||||
|
||||
if rules != dynamic.rules:
|
||||
record = record.copy()
|
||||
record.dynamic.rules = rules
|
||||
|
||||
@@ -9,6 +9,7 @@ from __future__ import absolute_import, division, print_function, \
|
||||
class BaseSource(object):
|
||||
|
||||
SUPPORTS_MUTLIVALUE_PTR = False
|
||||
SUPPORTS_POOL_VALUE_UP = False
|
||||
|
||||
def __init__(self, id):
|
||||
self.id = id
|
||||
|
||||
Reference in New Issue
Block a user