mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
Switch to using tuples for _mod_keyer
This commit is contained in:
@@ -469,9 +469,9 @@ class _Route53GeoRecord(_Route53Record):
|
||||
|
||||
|
||||
_mod_keyer_action_order = {
|
||||
'DELETE': '0', # Delete things first
|
||||
'CREATE': '1', # Then Create things
|
||||
'UPSERT': '2', # Upsert things last
|
||||
'DELETE': 0, # Delete things first
|
||||
'CREATE': 1, # Then Create things
|
||||
'UPSERT': 2, # Upsert things last
|
||||
}
|
||||
|
||||
|
||||
@@ -483,18 +483,18 @@ def _mod_keyer(mod):
|
||||
# name/id of the rrset
|
||||
|
||||
if rrset.get('GeoLocation', False):
|
||||
return '{}3{}'.format(action_order, rrset['SetIdentifier'])
|
||||
return (action_order, 3, rrset['SetIdentifier'])
|
||||
elif rrset.get('AliasTarget', False):
|
||||
# We use an alias
|
||||
if rrset.get('Failover', False) == 'SECONDARY':
|
||||
# We're a secondary we'll ref primaries
|
||||
return '{}2{}'.format(action_order, rrset['Name'])
|
||||
return (action_order, 2, rrset['Name'])
|
||||
else:
|
||||
# We're a primary we'll ref values
|
||||
return '{}1{}'.format(action_order, rrset['Name'])
|
||||
return (action_order, 1, rrset['Name'])
|
||||
|
||||
# We're just a plain value, these come first
|
||||
return '{}0{}'.format(action_order, rrset['Name'])
|
||||
return (action_order, 0, rrset['Name'])
|
||||
|
||||
|
||||
class Route53Provider(BaseProvider):
|
||||
|
@@ -2273,7 +2273,7 @@ class TestModKeyer(TestCase):
|
||||
# First "column"
|
||||
|
||||
# Deletes come first
|
||||
self.assertEquals('00something', _mod_keyer({
|
||||
self.assertEquals((0, 0, 'something'), _mod_keyer({
|
||||
'Action': 'DELETE',
|
||||
'ResourceRecordSet': {
|
||||
'Name': 'something',
|
||||
@@ -2281,7 +2281,7 @@ class TestModKeyer(TestCase):
|
||||
}))
|
||||
|
||||
# Creates come next
|
||||
self.assertEquals('10another', _mod_keyer({
|
||||
self.assertEquals((1, 0, 'another'), _mod_keyer({
|
||||
'Action': 'CREATE',
|
||||
'ResourceRecordSet': {
|
||||
'Name': 'another',
|
||||
@@ -2289,7 +2289,7 @@ class TestModKeyer(TestCase):
|
||||
}))
|
||||
|
||||
# Then upserts
|
||||
self.assertEquals('20last', _mod_keyer({
|
||||
self.assertEquals((2, 0, 'last'), _mod_keyer({
|
||||
'Action': 'UPSERT',
|
||||
'ResourceRecordSet': {
|
||||
'Name': 'last',
|
||||
@@ -2299,7 +2299,7 @@ class TestModKeyer(TestCase):
|
||||
# Second "column" value records tested above
|
||||
|
||||
# AliasTarget primary second (to value)
|
||||
self.assertEquals('01thing', _mod_keyer({
|
||||
self.assertEquals((0, 1, 'thing'), _mod_keyer({
|
||||
'Action': 'DELETE',
|
||||
'ResourceRecordSet': {
|
||||
'AliasTarget': 'some-target',
|
||||
@@ -2309,7 +2309,7 @@ class TestModKeyer(TestCase):
|
||||
}))
|
||||
|
||||
# AliasTarget secondary third
|
||||
self.assertEquals('02thing', _mod_keyer({
|
||||
self.assertEquals((0, 2, 'thing'), _mod_keyer({
|
||||
'Action': 'DELETE',
|
||||
'ResourceRecordSet': {
|
||||
'AliasTarget': 'some-target',
|
||||
@@ -2319,7 +2319,7 @@ class TestModKeyer(TestCase):
|
||||
}))
|
||||
|
||||
# GeoLocation fourth
|
||||
self.assertEquals('03some-id', _mod_keyer({
|
||||
self.assertEquals((0, 3, 'some-id'), _mod_keyer({
|
||||
'Action': 'DELETE',
|
||||
'ResourceRecordSet': {
|
||||
'GeoLocation': 'some-target',
|
||||
|
Reference in New Issue
Block a user