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 = {
|
_mod_keyer_action_order = {
|
||||||
'DELETE': '0', # Delete things first
|
'DELETE': 0, # Delete things first
|
||||||
'CREATE': '1', # Then Create things
|
'CREATE': 1, # Then Create things
|
||||||
'UPSERT': '2', # Upsert things last
|
'UPSERT': 2, # Upsert things last
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -483,18 +483,18 @@ def _mod_keyer(mod):
|
|||||||
# name/id of the rrset
|
# name/id of the rrset
|
||||||
|
|
||||||
if rrset.get('GeoLocation', False):
|
if rrset.get('GeoLocation', False):
|
||||||
return '{}3{}'.format(action_order, rrset['SetIdentifier'])
|
return (action_order, 3, rrset['SetIdentifier'])
|
||||||
elif rrset.get('AliasTarget', False):
|
elif rrset.get('AliasTarget', False):
|
||||||
# We use an alias
|
# We use an alias
|
||||||
if rrset.get('Failover', False) == 'SECONDARY':
|
if rrset.get('Failover', False) == 'SECONDARY':
|
||||||
# We're a secondary we'll ref primaries
|
# We're a secondary we'll ref primaries
|
||||||
return '{}2{}'.format(action_order, rrset['Name'])
|
return (action_order, 2, rrset['Name'])
|
||||||
else:
|
else:
|
||||||
# We're a primary we'll ref values
|
# 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
|
# 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):
|
class Route53Provider(BaseProvider):
|
||||||
|
|||||||
@@ -2273,7 +2273,7 @@ class TestModKeyer(TestCase):
|
|||||||
# First "column"
|
# First "column"
|
||||||
|
|
||||||
# Deletes come first
|
# Deletes come first
|
||||||
self.assertEquals('00something', _mod_keyer({
|
self.assertEquals((0, 0, 'something'), _mod_keyer({
|
||||||
'Action': 'DELETE',
|
'Action': 'DELETE',
|
||||||
'ResourceRecordSet': {
|
'ResourceRecordSet': {
|
||||||
'Name': 'something',
|
'Name': 'something',
|
||||||
@@ -2281,7 +2281,7 @@ class TestModKeyer(TestCase):
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
# Creates come next
|
# Creates come next
|
||||||
self.assertEquals('10another', _mod_keyer({
|
self.assertEquals((1, 0, 'another'), _mod_keyer({
|
||||||
'Action': 'CREATE',
|
'Action': 'CREATE',
|
||||||
'ResourceRecordSet': {
|
'ResourceRecordSet': {
|
||||||
'Name': 'another',
|
'Name': 'another',
|
||||||
@@ -2289,7 +2289,7 @@ class TestModKeyer(TestCase):
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
# Then upserts
|
# Then upserts
|
||||||
self.assertEquals('20last', _mod_keyer({
|
self.assertEquals((2, 0, 'last'), _mod_keyer({
|
||||||
'Action': 'UPSERT',
|
'Action': 'UPSERT',
|
||||||
'ResourceRecordSet': {
|
'ResourceRecordSet': {
|
||||||
'Name': 'last',
|
'Name': 'last',
|
||||||
@@ -2299,7 +2299,7 @@ class TestModKeyer(TestCase):
|
|||||||
# Second "column" value records tested above
|
# Second "column" value records tested above
|
||||||
|
|
||||||
# AliasTarget primary second (to value)
|
# AliasTarget primary second (to value)
|
||||||
self.assertEquals('01thing', _mod_keyer({
|
self.assertEquals((0, 1, 'thing'), _mod_keyer({
|
||||||
'Action': 'DELETE',
|
'Action': 'DELETE',
|
||||||
'ResourceRecordSet': {
|
'ResourceRecordSet': {
|
||||||
'AliasTarget': 'some-target',
|
'AliasTarget': 'some-target',
|
||||||
@@ -2309,7 +2309,7 @@ class TestModKeyer(TestCase):
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
# AliasTarget secondary third
|
# AliasTarget secondary third
|
||||||
self.assertEquals('02thing', _mod_keyer({
|
self.assertEquals((0, 2, 'thing'), _mod_keyer({
|
||||||
'Action': 'DELETE',
|
'Action': 'DELETE',
|
||||||
'ResourceRecordSet': {
|
'ResourceRecordSet': {
|
||||||
'AliasTarget': 'some-target',
|
'AliasTarget': 'some-target',
|
||||||
@@ -2319,7 +2319,7 @@ class TestModKeyer(TestCase):
|
|||||||
}))
|
}))
|
||||||
|
|
||||||
# GeoLocation fourth
|
# GeoLocation fourth
|
||||||
self.assertEquals('03some-id', _mod_keyer({
|
self.assertEquals((0, 3, 'some-id'), _mod_keyer({
|
||||||
'Action': 'DELETE',
|
'Action': 'DELETE',
|
||||||
'ResourceRecordSet': {
|
'ResourceRecordSet': {
|
||||||
'GeoLocation': 'some-target',
|
'GeoLocation': 'some-target',
|
||||||
|
|||||||
Reference in New Issue
Block a user