From 998e08ee6eabe70346d1cd1fbdf0cc39d7bb4beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chris=20Da=C3=9Fler?= Date: Sun, 26 May 2024 16:33:37 +0200 Subject: [PATCH] fix(): Check if secrets file exists --- .../src/spiffworkflow_backend/config/default.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py b/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py index be04cbb2..4ba38024 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/config/default.py @@ -1,5 +1,5 @@ import re -from os import environ +from os import environ, path from typing import Any from spiffworkflow_backend.config.normalized_environment import normalized_environment @@ -21,9 +21,12 @@ def config_from_env(variable_name: str, *, default: str | bool | int | None = No if value_from_file.startswith("/run/secrets"): # rewrite variable name: remove _FILE variable_name = variable_name.removesuffix("_FILE") - print(variable_name) - with open(value_from_file) as f: - value_to_return = f.readline() + + if path.exists(value_from_file): + with open(value_from_file) as f: + value_to_return = f.readline() + else: + value_to_return = None if value_from_env is not None: if isinstance(default, bool):