Browse Source

Add protocol and port to octodns.healthcheck configurables

pull/67/head
Ross McFarland 8 years ago
parent
commit
9752cb0a12
No known key found for this signature in database GPG Key ID: 61C10C4FC8FE4A89
2 changed files with 24 additions and 3 deletions
  1. +17
    -3
      octodns/record.py
  2. +7
    -0
      tests/test_octodns_record.py

+ 17
- 3
octodns/record.py View File

@ -153,6 +153,13 @@ class Record(object):
def included(self): def included(self):
return self._octodns.get('included', []) return self._octodns.get('included', [])
@property
def healthcheck_host(self):
try:
return self._octodns['healthcheck']['host']
except KeyError:
return self.fqdn[:-1]
@property @property
def healthcheck_path(self): def healthcheck_path(self):
try: try:
@ -161,11 +168,18 @@ class Record(object):
return '/_dns' return '/_dns'
@property @property
def healthcheck_host(self):
def healthcheck_protocol(self):
try: try:
return self._octodns['healthcheck']['host']
return self._octodns['healthcheck']['protocol']
except KeyError: except KeyError:
return self.fqdn[:-1]
return 'https'
@property
def healthcheck_port(self):
try:
return self._octodns['healthcheck']['port']
except KeyError:
return 443
def changes(self, other, target): def changes(self, other, target):
# We're assuming we have the same name and type if we're being compared # We're assuming we have the same name and type if we're being compared


+ 7
- 0
tests/test_octodns_record.py View File

@ -755,11 +755,16 @@ class TestRecord(TestCase):
'healthcheck': { 'healthcheck': {
'path': '/_ready', 'path': '/_ready',
'host': 'bleep.bloop', 'host': 'bleep.bloop',
'protocol': 'http',
'port': 8080,
} }
} }
}) })
self.assertEquals('/_ready', new.healthcheck_path) self.assertEquals('/_ready', new.healthcheck_path)
self.assertEquals('bleep.bloop', new.healthcheck_host) self.assertEquals('bleep.bloop', new.healthcheck_host)
self.assertEquals('http', new.healthcheck_protocol)
self.assertEquals(8080, new.healthcheck_port)
new = Record.new(self.zone, 'a', { new = Record.new(self.zone, 'a', {
'ttl': 44, 'ttl': 44,
'type': 'A', 'type': 'A',
@ -767,6 +772,8 @@ class TestRecord(TestCase):
}) })
self.assertEquals('/_dns', new.healthcheck_path) self.assertEquals('/_dns', new.healthcheck_path)
self.assertEquals('a.unit.tests', new.healthcheck_host) self.assertEquals('a.unit.tests', new.healthcheck_host)
self.assertEquals('https', new.healthcheck_protocol)
self.assertEquals(443, new.healthcheck_port)
def test_inored(self): def test_inored(self):
new = Record.new(self.zone, 'txt', { new = Record.new(self.zone, 'txt', {


Loading…
Cancel
Save