fix typing issues and fix issue i introduced

This commit is contained in:
burnettk 2024-05-28 17:01:09 -04:00
parent 59c697e9bf
commit 7a76ecba50
No known key found for this signature in database
2 changed files with 13 additions and 12 deletions

View File

@ -20,17 +20,18 @@ def config_from_env(variable_name: str, *, default: str | bool | int | None = No
# using docker secrets - put file contents to env value
if variable_name.endswith("_FILE"):
value_from_file = default if value_from_env is None else value_from_env
if value_from_file and value_from_file.startswith("/run/secrets"):
# rewrite variable name: remove _FILE
variable_name = variable_name.removesuffix("_FILE")
try:
with open(value_from_file) as file:
value_to_return = file.read().strip() # Read entire content and strip any extra whitespace
except FileNotFoundError:
value_to_return = None # Handle the case where the file does not exist
except Exception as e:
current_app.logger.error(f"Error reading from {value_from_file}: {str(e)}")
value_to_return = None # Handle other potential errors
if value_from_file:
if isinstance(value_from_file, str) and value_from_file.startswith("/run/secrets"):
# rewrite variable name: remove _FILE
variable_name = variable_name.removesuffix("_FILE")
try:
with open(value_from_file) as file:
value_to_return = file.read().strip() # Read entire content and strip any extra whitespace
except FileNotFoundError:
value_to_return = None # Handle the case where the file does not exist
except Exception as e:
current_app.logger.error(f"Error reading from {value_from_file}: {str(e)}")
value_to_return = None # Handle other potential errors
if value_from_env is not None:
if isinstance(default, bool):

View File

@ -77,7 +77,7 @@ class ReferenceCacheModel(SpiffworkflowBaseDBModel):
file_name: str = db.Column(db.String(255), nullable=False)
# relative to SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR
relative_location: int = db.Column(db.String(255), index=True, nullable=False)
relative_location: str = db.Column(db.String(255), index=True, nullable=False)
properties: dict | None = db.Column(db.JSON)
# has_lanes = db.Column(db.Boolean())