aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2021-08-29 14:08:01 +0200
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2021-08-29 14:08:01 +0200
commit284c2646c6898ec273feba251716bf610a31dc31 (patch)
treeec0c1696b4be1ab2d6bbe1e2abb6ccd218759119
parent968ad127f39023e0cd560fa3e2f9516968043616 (diff)
downloadoctodns-custom-provider-284c2646c6898ec273feba251716bf610a31dc31.tar.gz
soa.serial allow environment as serial number
-rw-r--r--README.md2
-rwxr-xr-xoctodns-custom-providers/provider/zonefile.py8
-rwxr-xr-xsetup.py2
3 files changed, 11 insertions, 1 deletions
diff --git a/README.md b/README.md
index 1f00ab8..152dc53 100644
--- a/README.md
+++ b/README.md
@@ -7,6 +7,8 @@ Custom [OctoDNS](https://github.com/octodns/octodns) Providers/Sources I wrote f
OctoDNS only provides a ZoneFile source. This Provider can create a BIND compatible ZoneFile.
It can NOT be used as a source. Use the builtin OctoDNS ZoneFile source instead.
+soa.serial can be used with `env/` keyword to use environment variable as Serialnumber
+
Example
```
diff --git a/octodns-custom-providers/provider/zonefile.py b/octodns-custom-providers/provider/zonefile.py
index f03f578..6df04e1 100755
--- a/octodns-custom-providers/provider/zonefile.py
+++ b/octodns-custom-providers/provider/zonefile.py
@@ -6,6 +6,8 @@ import dns.zone
import dns.rdataclass
import dns.rdatatype
+import os
+
class RdataParameterException(Exception):
def __init__(self, msg):
super().__init__(msg)
@@ -58,6 +60,12 @@ class ZoneFileProvider(BaseProvider):
self.soa = soa
self.soa_ttl = soa_ttl
+ # OctoDNS does not recursively check dicts for 'env/' keyword
+ # TODO Error handling
+ serial = self.soa['serial']
+ if type(serial) == str and serial.startswith('env/'):
+ self.soa['serial'] = int(os.environ[ serial.split('/',1)[1] ])
+
super(ZoneFileProvider, self).__init__(id)
def populate(self, zone, target=False, lenient=False):
diff --git a/setup.py b/setup.py
index 261dddc..2292e1a 100755
--- a/setup.py
+++ b/setup.py
@@ -3,7 +3,7 @@ import setuptools
setup(
name='octodns-custom-providers',
- version='0.3.0',
+ version='0.3.1',
author="Jonas Gunz",
author_mail="himself@jonasgunz.de",
description="Custom sources for OctoDNS",