diff --git a/.changelog/6c6407b8ddf345ecb2e850e34d1ce328.md b/.changelog/6c6407b8ddf345ecb2e850e34d1ce328.md new file mode 100644 index 0000000..4f36618 --- /dev/null +++ b/.changelog/6c6407b8ddf345ecb2e850e34d1ce328.md @@ -0,0 +1,4 @@ +--- +type: patch +--- +Removes the final dot from zone_*name and record_*fqdn templating variables \ No newline at end of file diff --git a/octodns/processor/templating.py b/octodns/processor/templating.py index c514bec..6477872 100644 --- a/octodns/processor/templating.py +++ b/octodns/processor/templating.py @@ -62,9 +62,9 @@ class Templating(BaseProcessor): def process_source_zone(self, desired, sources): sources = sources or [] zone_params = { - 'zone_name': desired.decoded_name, - 'zone_decoded_name': desired.decoded_name, - 'zone_encoded_name': desired.name, + 'zone_name': desired.decoded_name.rstrip('.'), + 'zone_decoded_name': desired.decoded_name.rstrip('.'), + 'zone_encoded_name': desired.name.rstrip('.'), 'zone_num_records': len(desired.records), 'zone_source_ids': ', '.join(s.id for s in sources), # add any extra context provided to us, if the value is a callable @@ -81,9 +81,9 @@ class Templating(BaseProcessor): 'record_name': record.decoded_name, 'record_decoded_name': record.decoded_name, 'record_encoded_name': record.name, - 'record_fqdn': record.decoded_fqdn, - 'record_decoded_fqdn': record.decoded_fqdn, - 'record_encoded_fqdn': record.fqdn, + 'record_fqdn': record.decoded_fqdn.rstrip('.'), + 'record_decoded_fqdn': record.decoded_fqdn.rstrip('.'), + 'record_encoded_fqdn': record.fqdn.rstrip('.'), 'record_type': record._type, 'record_ttl': record.ttl, 'record_source_id': record.source.id if record.source else None, diff --git a/tests/test_octodns_processor_templating.py b/tests/test_octodns_processor_templating.py index 94472d8..7c90706 100644 --- a/tests/test_octodns_processor_templating.py +++ b/tests/test_octodns_processor_templating.py @@ -74,7 +74,7 @@ class TemplatingTest(TestCase): { 'type': 'CNAME', 'ttl': 42, - 'value': '_cname.{zone_name}something.else.', + 'value': '_cname.{zone_name}.something.else.', }, lenient=True, ) @@ -107,7 +107,7 @@ class TemplatingTest(TestCase): { 'type': 'TXT', 'ttl': 42, - 'value': 'There are {zone_num_records} record(s) in {zone_name}', + 'value': 'There are {zone_num_records} record(s) in {zone_name}.', }, ) zone.add_record(txt) @@ -156,7 +156,7 @@ class TemplatingTest(TestCase): { 'type': 'TXT', 'ttl': 42, - 'value': 'There are {zone_num_records} record(s) in {zone_name}', + 'value': 'There are {zone_num_records} record(s) in {zone_name}.', }, source=record_source, ) @@ -172,15 +172,15 @@ class TemplatingTest(TestCase): 'record_name': 'txt', 'record_decoded_name': 'txt', 'record_encoded_name': 'txt', - 'record_fqdn': 'txt.unit.tests.', - 'record_decoded_fqdn': 'txt.unit.tests.', - 'record_encoded_fqdn': 'txt.unit.tests.', + 'record_fqdn': 'txt.unit.tests', + 'record_decoded_fqdn': 'txt.unit.tests', + 'record_encoded_fqdn': 'txt.unit.tests', 'record_type': 'TXT', 'record_ttl': 42, 'record_source_id': 'record', - 'zone_name': 'unit.tests.', - 'zone_decoded_name': 'unit.tests.', - 'zone_encoded_name': 'unit.tests.', + 'zone_name': 'unit.tests', + 'zone_decoded_name': 'unit.tests', + 'zone_encoded_name': 'unit.tests', 'zone_num_records': 1, 'zone_source_ids': 'record, other', }