mirror of
https://github.com/github/octodns.git
synced 2024-05-11 05:55:00 +00:00
_build_kwargs fix, don't convert int-y things to floats
This commit is contained in:
@@ -388,10 +388,14 @@ class Manager(object):
|
||||
f'Incorrect provider config, missing env var {env_var}, {source.context}'
|
||||
)
|
||||
try:
|
||||
# try converting the value to a number to see if it
|
||||
# converts
|
||||
v = float(v)
|
||||
if '.' in v:
|
||||
# has a dot, try converting it to a float
|
||||
v = float(v)
|
||||
else:
|
||||
# no dot, try converting it to an int
|
||||
v = int(v)
|
||||
except ValueError:
|
||||
# just leave it as a string
|
||||
pass
|
||||
|
||||
kwargs[k] = v
|
||||
|
||||
@@ -1133,6 +1133,7 @@ class TestManager(TestCase):
|
||||
|
||||
environ['OCTODNS_TEST_1'] = '42'
|
||||
environ['OCTODNS_TEST_2'] = 'string'
|
||||
environ['OCTODNS_TEST_3'] = '43.44'
|
||||
|
||||
# empty
|
||||
self.assertEqual({}, manager._build_kwargs({}))
|
||||
@@ -1202,6 +1203,18 @@ class TestManager(TestCase):
|
||||
),
|
||||
)
|
||||
|
||||
# types/conversion
|
||||
self.assertEqual(
|
||||
{'int': 42, 'string': 'string', 'float': 43.44},
|
||||
manager._build_kwargs(
|
||||
{
|
||||
'int': 'env/OCTODNS_TEST_1',
|
||||
'string': 'env/OCTODNS_TEST_2',
|
||||
'float': 'env/OCTODNS_TEST_3',
|
||||
}
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
class TestMainThreadExecutor(TestCase):
|
||||
def test_success(self):
|
||||
|
||||
Reference in New Issue
Block a user