diff options
author | James Falcon <TheRealFalcon@users.noreply.github.com> | 2020-12-15 10:31:27 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-15 11:31:27 -0500 |
commit | 2af3f6d7247d0ef0dd3d4c287c8d8e71fda5173a (patch) | |
tree | f7323fdc73f2729ecfd6350b86346bec7aa6fc7d | |
parent | 3339a5a4680e79fecb09907089239e6749e08a54 (diff) | |
download | vyos-cloud-init-2af3f6d7247d0ef0dd3d4c287c8d8e71fda5173a.tar.gz vyos-cloud-init-2af3f6d7247d0ef0dd3d4c287c8d8e71fda5173a.zip |
Ensure overriding test vars with env vars works for booleans (#727)
-rw-r--r-- | tests/integration_tests/integration_settings.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/tests/integration_tests/integration_settings.py b/tests/integration_tests/integration_settings.py index 9948d479..d7e02f04 100644 --- a/tests/integration_tests/integration_settings.py +++ b/tests/integration_tests/integration_settings.py @@ -1,6 +1,8 @@ # This file is part of cloud-init. See LICENSE file for license information. import os +from distutils.util import strtobool + ################################################################## # LAUNCH SETTINGS ################################################################## @@ -109,6 +111,12 @@ except ImportError: # Perhaps a bit too hacky, but it works :) current_settings = [var for var in locals() if var.isupper()] for setting in current_settings: - globals()[setting] = os.getenv( + env_setting = os.getenv( 'CLOUD_INIT_{}'.format(setting), globals()[setting] ) + if isinstance(env_setting, str): + try: + env_setting = bool(strtobool(env_setting.strip())) + except ValueError: + pass + globals()[setting] = env_setting |