From 9752cb0a126fbed0c3d8951aec00682a8186b301 Mon Sep 17 00:00:00 2001 From: Ross McFarland Date: Sat, 31 Mar 2018 13:10:06 -0700 Subject: [PATCH] Add protocol and port to octodns.healthcheck configurables --- octodns/record.py | 20 +++++++++++++++++--- tests/test_octodns_record.py | 7 +++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/octodns/record.py b/octodns/record.py index c60ecd6..795ad71 100644 --- a/octodns/record.py +++ b/octodns/record.py @@ -153,6 +153,13 @@ class Record(object): def included(self): return self._octodns.get('included', []) + @property + def healthcheck_host(self): + try: + return self._octodns['healthcheck']['host'] + except KeyError: + return self.fqdn[:-1] + @property def healthcheck_path(self): try: @@ -161,11 +168,18 @@ class Record(object): return '/_dns' @property - def healthcheck_host(self): + def healthcheck_protocol(self): try: - return self._octodns['healthcheck']['host'] + return self._octodns['healthcheck']['protocol'] 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): # We're assuming we have the same name and type if we're being compared diff --git a/tests/test_octodns_record.py b/tests/test_octodns_record.py index 45d790b..e23808b 100644 --- a/tests/test_octodns_record.py +++ b/tests/test_octodns_record.py @@ -755,11 +755,16 @@ class TestRecord(TestCase): 'healthcheck': { 'path': '/_ready', 'host': 'bleep.bloop', + 'protocol': 'http', + 'port': 8080, } } }) self.assertEquals('/_ready', new.healthcheck_path) 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', { 'ttl': 44, 'type': 'A', @@ -767,6 +772,8 @@ class TestRecord(TestCase): }) self.assertEquals('/_dns', new.healthcheck_path) self.assertEquals('a.unit.tests', new.healthcheck_host) + self.assertEquals('https', new.healthcheck_protocol) + self.assertEquals(443, new.healthcheck_port) def test_inored(self): new = Record.new(self.zone, 'txt', {