Browse Source

Removes the final dot from zone_*name and record_*fqdn templating variables

pull/1278/head
Jonathan Leroy 5 months ago
parent
commit
d75e672fe1
No known key found for this signature in database GPG Key ID: CF226DF21118649E
3 changed files with 19 additions and 15 deletions
  1. +4
    -0
      .changelog/6c6407b8ddf345ecb2e850e34d1ce328.md
  2. +6
    -6
      octodns/processor/templating.py
  3. +9
    -9
      tests/test_octodns_processor_templating.py

+ 4
- 0
.changelog/6c6407b8ddf345ecb2e850e34d1ce328.md View File

@ -0,0 +1,4 @@
---
type: patch
---
Removes the final dot from zone_*name and record_*fqdn templating variables

+ 6
- 6
octodns/processor/templating.py View File

@ -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,


+ 9
- 9
tests/test_octodns_processor_templating.py View File

@ -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',
}


Loading…
Cancel
Save