mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
deprecation.deprecated, use official mechinism for deprecations
This commit is contained in:
9
octodns/deprecation.py
Normal file
9
octodns/deprecation.py
Normal file
@@ -0,0 +1,9 @@
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
from warnings import warn
|
||||
|
||||
|
||||
def deprecated(message, stacklevel=2):
|
||||
warn(message, DeprecationWarning, stacklevel=stacklevel)
|
||||
@@ -10,6 +10,7 @@ from dns.resolver import Answer
|
||||
|
||||
from octodns.record.base import Record
|
||||
|
||||
from ..deprecation import deprecated
|
||||
from .base import BaseProcessor, ProcessorException
|
||||
|
||||
|
||||
@@ -55,7 +56,7 @@ class SpfDnsLookupProcessor(BaseProcessor):
|
||||
|
||||
def __init__(self, name):
|
||||
self.log.debug(f"SpfDnsLookupProcessor: {name}")
|
||||
self.log.warning(
|
||||
deprecated(
|
||||
'SpfDnsLookupProcessor is DEPRECATED in favor of the version relocated into octodns-spf and will be removed in 2.0'
|
||||
)
|
||||
super().__init__(name)
|
||||
|
||||
@@ -7,6 +7,7 @@ from collections import defaultdict
|
||||
from os import listdir, makedirs
|
||||
from os.path import isdir, isfile, join
|
||||
|
||||
from ..deprecation import deprecated
|
||||
from ..record import Record
|
||||
from ..yaml import safe_dump, safe_load
|
||||
from . import ProviderException
|
||||
@@ -466,6 +467,6 @@ class SplitYamlProvider(YamlProvider):
|
||||
}
|
||||
)
|
||||
super().__init__(id, directory, *args, **kwargs)
|
||||
self.log.warning(
|
||||
'__init__: DEPRECATED use YamlProvider with split_extension, split_catchall, and disable_zonefile instead, will go away in v2.0'
|
||||
deprecated(
|
||||
'SplitYamlProvider is DEPRECATED, use YamlProvider with split_extension, split_catchall, and disable_zonefile instead, will go away in v2.0'
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
from logging import getLogger
|
||||
|
||||
from ..deprecation import deprecated
|
||||
from ..equality import EqualityTupleMixin
|
||||
from .base import Record, ValuesMixin
|
||||
from .rr import RrParseError
|
||||
@@ -48,8 +49,8 @@ class DsValue(EqualityTupleMixin, dict):
|
||||
# it is safe to assume if public_key or flags are defined then it is "old" style
|
||||
# A DS record without public_key doesn't make any sense and shouldn't have validated previously
|
||||
if "public_key" in value or "flags" in value:
|
||||
cls.log.warning(
|
||||
'"algorithm", "flags", "public_key", and "protocol" support is DEPRECATED and will be removed in 2.0'
|
||||
deprecated(
|
||||
'DS properties "algorithm", "flags", "public_key", and "protocol" support is DEPRECATED and will be removed in 2.0'
|
||||
)
|
||||
try:
|
||||
int(value['flags'])
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import re
|
||||
from logging import getLogger
|
||||
|
||||
from ..deprecation import deprecated
|
||||
from ..equality import EqualityTupleMixin
|
||||
from .base import ValuesMixin
|
||||
from .change import Update
|
||||
@@ -141,8 +142,8 @@ class _GeoMixin(ValuesMixin):
|
||||
reasons = super().validate(name, fqdn, data)
|
||||
try:
|
||||
geo = dict(data['geo'])
|
||||
cls.log.warning(
|
||||
'NOTICE: `geo` record support is deprecated and should be migrated to `dynamic` records'
|
||||
deprecated(
|
||||
'`geo` records are DEPRECATED. `dynamic` records should be used instead. Will be removed in 2.0'
|
||||
)
|
||||
for code, values in geo.items():
|
||||
reasons.extend(GeoValue._validate_geo(code))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#
|
||||
#
|
||||
|
||||
from ..deprecation import deprecated
|
||||
from .base import Record
|
||||
from .chunked import _ChunkedValue, _ChunkedValuesMixin
|
||||
|
||||
@@ -12,7 +13,7 @@ class SpfRecord(_ChunkedValuesMixin, Record):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.log.warning(
|
||||
deprecated(
|
||||
'The SPF record type is DEPRECATED in favor of TXT values and will become an ValidationError in 2.0'
|
||||
)
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import re
|
||||
from collections import defaultdict
|
||||
from logging import getLogger
|
||||
|
||||
from .deprecation import deprecated
|
||||
from .idna import idna_decode, idna_encode
|
||||
from .record import Create, Delete
|
||||
|
||||
@@ -197,8 +198,9 @@ class Zone(object):
|
||||
|
||||
# TODO: delete this at v2.0.0rc0
|
||||
def _remove_record(self, record):
|
||||
self.log.warning(
|
||||
'_remove_record: method has been deprecated, used remove_record instead'
|
||||
deprecated(
|
||||
'_remove_record has been deprecated, used remove_record instead. Will be removed in 2.0',
|
||||
stacklevel=3,
|
||||
)
|
||||
return self.remove_record(record)
|
||||
|
||||
|
||||
@@ -213,24 +213,6 @@ class TestRecordGeoCodes(TestCase):
|
||||
self.assertTrue(c >= b)
|
||||
|
||||
def test_validation(self):
|
||||
with self.assertLogs('Record', level='WARNING') as cm:
|
||||
Record.new(
|
||||
self.zone,
|
||||
'',
|
||||
{
|
||||
'geo': {'NA': ['1.2.3.5'], 'NA-US': ['1.2.3.5', '1.2.3.6']},
|
||||
'type': 'A',
|
||||
'ttl': 600,
|
||||
'value': '1.2.3.4',
|
||||
},
|
||||
)
|
||||
self.assertEqual(
|
||||
[
|
||||
'WARNING:Record:NOTICE: `geo` record support is deprecated and should be migrated to `dynamic` records'
|
||||
],
|
||||
cm.output,
|
||||
)
|
||||
|
||||
# invalid ip address
|
||||
with self.assertRaises(ValidationError) as ctx:
|
||||
Record.new(
|
||||
|
||||
Reference in New Issue
Block a user