From 6ba6a32628baa85bf7a9d4269f8e6969c7450559 Mon Sep 17 00:00:00 2001 From: Nikolai Peukhov Date: Tue, 17 Dec 2024 16:58:42 -0300 Subject: [PATCH] add env conversion --- agent/worker/constants.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/agent/worker/constants.py b/agent/worker/constants.py index 45a96f6..3b4f8de 100644 --- a/agent/worker/constants.py +++ b/agent/worker/constants.py @@ -189,8 +189,11 @@ def get_optional_defaults(): return _OPTIONAL_DEFAULTS.copy() -def read_optional_setting(name): - return os.getenv(name, _OPTIONAL_DEFAULTS[name]) +def read_optional_setting(name, postprocess_fn = None): + value = os.getenv(name, _OPTIONAL_DEFAULTS[name]) + if postprocess_fn is not None: + return postprocess_fn(value) + return value def HOST_DIR(): @@ -544,7 +547,7 @@ def DISABLE_TELEMETRY(): def REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS(): - return read_optional_setting(_REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS) + return read_optional_setting(_REMOVE_IDLE_DOCKER_IMAGE_AFTER_X_DAYS, lambda x: int(x)) def AGENT_ID():