Skip to content

Commit

Permalink
update the settings (#60)
Browse files Browse the repository at this point in the history
* update the settings to handle situations where the variable has not been cleaned

* fix version typo
  • Loading branch information
SerRichard authored Oct 24, 2024
1 parent 77c499c commit fb2d492
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions openeo_fastapi/client/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ def ensure_endswith_slash(cls, v: str) -> str:
return v.__add__("/")

@validator("OIDC_POLICIES", pre=True)
def split_oidc_policies_str_to_list(cls, v: str) -> str:
def split_oidc_policies_str_to_list(cls, v: list) -> str:
"""Ensure the OIDC_POLICIES are split and formatted correctly."""

if isinstance(v, str):
# We shouldn't have a string here. But in some cases where the settings where taken from code and not an env variable
# the config function parse_env_var will not execute. Reclean the value here if that is the case.
v = [str(x) for x in v.split("&&") if x != ""]

if not v:
return v

Expand All @@ -86,8 +91,6 @@ def parse_env_var(cls, field_name: str, raw_val: str) -> Any:
"""Parse any variables and handle and csv lists into python list type."""
if field_name == "STAC_COLLECTIONS_WHITELIST":
return [str(x) for x in raw_val.split(",")]
elif field_name == "OIDC_ROLES":
return [str(x) for x in raw_val.split(",")]
elif field_name == "OIDC_POLICIES":
return [str(x) for x in raw_val.split("&&")]
return [str(x) for x in raw_val.split("&&") if x != ""]
return cls.json_loads(raw_val)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openeo-fastapi"
version = "2024.9.2"
version = "2024.10.1"
description = "FastApi implementation conforming to the OpenEO Api specification."
authors = ["Sean Hoyal <sean.hoyal@external.eodc.eu>"]
readme = "README.md"
Expand Down

0 comments on commit fb2d492

Please sign in to comment.