1
0
mirror of https://github.com/github/octodns.git synced 2024-05-11 05:55:00 +00:00

Implement black formatting

This commit is contained in:
Ross McFarland
2022-07-04 12:27:39 -07:00
parent 392d8b516f
commit e116d26eec
101 changed files with 6403 additions and 5490 deletions

View File

@@ -2,5 +2,9 @@
#
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)

View File

@@ -2,8 +2,12 @@
#
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)
from logging import getLogger
@@ -34,8 +38,9 @@ class AcmeMangingProcessor(BaseProcessor):
def process_source_zone(self, desired, *args, **kwargs):
for record in desired.records:
if record._type == 'TXT' and \
record.name.startswith('_acme-challenge'):
if record._type == 'TXT' and record.name.startswith(
'_acme-challenge'
):
# We have a managed acme challenge record (owned by octoDNS) so
# we should mark it as such
record = record.copy()
@@ -51,10 +56,12 @@ class AcmeMangingProcessor(BaseProcessor):
for record in existing.records:
# Uses a startswith rather than == to ignore subdomain challenges,
# e.g. _acme-challenge.foo.domain.com when managing domain.com
if record._type == 'TXT' and \
record.name.startswith('_acme-challenge') and \
'*octoDNS*' not in record.values and \
record not in self._owned:
if (
record._type == 'TXT'
and record.name.startswith('_acme-challenge')
and '*octoDNS*' not in record.values
and record not in self._owned
):
self.log.info('_process: ignoring %s', record.fqdn)
existing.remove_record(record)

View File

@@ -2,21 +2,30 @@
# Ignores AWS ACM validation CNAME records.
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)
from logging import getLogger
logger = getLogger('Route53')
try:
logger.warning('octodns_route53 shimmed. Update your processor class to '
'octodns_route53.processor.AwsAcmMangingProcessor. '
'Shim will be removed in 1.0')
logger.warning(
'octodns_route53 shimmed. Update your processor class to '
'octodns_route53.processor.AwsAcmMangingProcessor. '
'Shim will be removed in 1.0'
)
from octodns_route53.processor import AwsAcmMangingProcessor
AwsAcmMangingProcessor # pragma: no cover
except ModuleNotFoundError:
logger.exception('AwsAcmMangingProcessor has been moved into a separate '
'module, octodns_route53 is now required. Processor '
'class should be updated to '
'octodns_route53.processor.AwsAcmMangingProcessor')
logger.exception(
'AwsAcmMangingProcessor has been moved into a separate '
'module, octodns_route53 is now required. Processor '
'class should be updated to '
'octodns_route53.processor.AwsAcmMangingProcessor'
)
raise

View File

@@ -2,12 +2,15 @@
#
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)
class BaseProcessor(object):
def __init__(self, name):
self.name = name

View File

@@ -2,14 +2,17 @@
#
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)
from .base import BaseProcessor
class TypeAllowlistFilter(BaseProcessor):
def __init__(self, name, allowlist):
super(TypeAllowlistFilter, self).__init__(name)
self.allowlist = set(allowlist)
@@ -26,7 +29,6 @@ class TypeAllowlistFilter(BaseProcessor):
class TypeRejectlistFilter(BaseProcessor):
def __init__(self, name, rejectlist):
super(TypeRejectlistFilter, self).__init__(name)
self.rejectlist = set(rejectlist)

View File

@@ -2,8 +2,12 @@
#
#
from __future__ import absolute_import, division, print_function, \
unicode_literals
from __future__ import (
absolute_import,
division,
print_function,
unicode_literals,
)
from collections import defaultdict
@@ -17,7 +21,6 @@ from .base import BaseProcessor
# delete. We'll take ownership of existing records that we're told to manage
# and thus "own" them going forward.
class OwnershipProcessor(BaseProcessor):
def __init__(self, name, txt_name='_owner', txt_value='*octodns*'):
super(OwnershipProcessor, self).__init__(name)
self.txt_name = txt_name
@@ -32,19 +35,21 @@ class OwnershipProcessor(BaseProcessor):
name = f'{self.txt_name}.{record._type}.{record_name}'
else:
name = f'{self.txt_name}.{record._type}'
txt = Record.new(desired, name, {
'type': 'TXT',
'ttl': 60,
'value': self.txt_value,
})
txt = Record.new(
desired,
name,
{'type': 'TXT', 'ttl': 60, 'value': self.txt_value},
)
desired.add_record(txt)
return desired
def _is_ownership(self, record):
return record._type == 'TXT' and \
record.name.startswith(self.txt_name) \
return (
record._type == 'TXT'
and record.name.startswith(self.txt_name)
and record.values == self._txt_values
)
def process_plan(self, plan, *args, **kwargs):
if not plan:
@@ -80,9 +85,11 @@ class OwnershipProcessor(BaseProcessor):
for change in plan.changes:
record = change.record
if not self._is_ownership(record) and \
record._type not in owned[record.name] and \
record.name != 'octodns-meta':
if (
not self._is_ownership(record)
and record._type not in owned[record.name]
and record.name != 'octodns-meta'
):
# It's not an ownership TXT, it's not owned, and it's not
# special we're going to ignore it
continue
@@ -92,8 +99,13 @@ class OwnershipProcessor(BaseProcessor):
filtered_changes.append(change)
if plan.changes != filtered_changes:
return Plan(plan.existing, plan.desired, filtered_changes,
plan.exists, plan.update_pcent_threshold,
plan.delete_pcent_threshold)
return Plan(
plan.existing,
plan.desired,
filtered_changes,
plan.exists,
plan.update_pcent_threshold,
plan.delete_pcent_threshold,
)
return plan