Browse Source

Give the option to use a private_key_file.

Transip sdk also supports a private_key_file,
so forwarding that option to the provider.
Could be handy in combination with k8s secrets.
pull/405/head
Maikel Poot 6 years ago
parent
commit
a035ee8c84
2 changed files with 24 additions and 3 deletions
  1. +11
    -3
      octodns/provider/transip.py
  2. +13
    -0
      tests/test_octodns_provider_transip.py

+ 11
- 3
octodns/provider/transip.py View File

@ -23,13 +23,16 @@ class TransipProvider(BaseProvider):
class: octodns.provider.transip.TransipProvider
# Your Transip account name (required)
account: yourname
# The api key (required)
# Path to a private key file (required if key is not used)
key_file: /path/to/file
# The api key as string (required if key_file is not used)
key: |
\'''
-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----
\'''
# if both `key_file` and `key` are presented `key_file` is used
'''
SUPPORTS_GEO = False
@ -41,13 +44,18 @@ class TransipProvider(BaseProvider):
TIMEOUT = 15
ROOT_RECORD = '@'
def __init__(self, id, account, key, *args, **kwargs):
def __init__(self, id, account, key=None, key_file=None, *args, **kwargs):
self.log = getLogger('TransipProvider[{}]'.format(id))
self.log.debug('__init__: id=%s, account=%s, token=***', id,
account)
super(TransipProvider, self).__init__(id, *args, **kwargs)
self._client = DomainService(account, key)
if key_file is not None:
self._client = DomainService(account, private_key_file=key_file)
elif key is not None:
self._client = DomainService(account, private_key=key)
else:
raise Exception('Missing `key` of `key_file` parameter in config')
self.account = account
self.key = key


+ 13
- 0
tests/test_octodns_provider_transip.py View File

@ -133,6 +133,19 @@ N4OiVz1I3rbZGYa396lpxO6ku8yCglisL1yrSP6DdEUp66ntpKVd
source.populate(expected)
return expected
def test_init(self):
with self.assertRaises(Exception) as ctx:
TransipProvider('test', 'unittest')
self.assertEquals(
str('Missing `key` of `key_file` parameter in config'),
str(ctx.exception))
TransipProvider('test', 'unittest', key=self.bogus_key)
# Existence and content of the key is tested in the SDK on client call
TransipProvider('test', 'unittest', key_file='/fake/path')
def test_populate(self):
_expected = self.make_expected()


Loading…
Cancel
Save