From b2d72d6603ea5915f62bc59590ac4af7c450e554 Mon Sep 17 00:00:00 2001 From: Khanh Ngo Date: Thu, 2 Apr 2020 09:41:26 +0700 Subject: [PATCH] Fix docker bool config value --- configs/docker_config.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/configs/docker_config.py b/configs/docker_config.py index 4abe50b..194da8c 100644 --- a/configs/docker_config.py +++ b/configs/docker_config.py @@ -63,6 +63,12 @@ legal_envvars_bool = ( # import everything from environment variables import os import sys + + +def str2bool(v): + return v.lower() in ("true", "yes", "1") + + for v in legal_envvars: ret = None @@ -70,7 +76,9 @@ for v in legal_envvars: # secrets feature if v + '_FILE' in os.environ: if v in os.environ: - raise AttributeError("Both {} and {} are set but are exclusive." .format(v, v + '_FILE')) + raise AttributeError( + "Both {} and {} are set but are exclusive.".format( + v, v + '_FILE')) with open(os.environ[v + '_FILE']) as f: ret = f.read() f.close() @@ -80,7 +88,7 @@ for v in legal_envvars: if ret is not None: if v in legal_envvars_bool: - ret = bool(ret) + ret = str2bool(ret) if v in legal_envvars_int: ret = int(ret) sys.modules[__name__].__dict__[v] = ret