File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
elasticsearch/stac_fastapi/elasticsearch
opensearch/stac_fastapi/opensearch Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -16,9 +16,16 @@ def _es_config() -> Dict[str, Any]:
1616 scheme = "https" if use_ssl else "http"
1717
1818 # Configure the hosts parameter with the correct scheme
19+ es_hosts = os .getenv ("ES_HOST" , "localhost" ).strip () # Default to localhost if ES_HOST is not set
20+ es_port = os .getenv ("ES_PORT" , "9200" ) # Default to 9200 if ES_PORT is not set
21+
22+ # Validate ES_HOST
23+ if not es_hosts :
24+ raise ValueError ("ES_HOST environment variable is empty or invalid." )
25+
1926 hosts = [
20- f"{ scheme } ://{ host .strip ()} :{ os . getenv ( 'ES_PORT' ) } "
21- for host in os . getenv ( "ES_HOST" ) .split ("," )
27+ f"{ scheme } ://{ host .strip ()} :{ es_port } "
28+ for host in es_hosts .split ("," )
2229 ]
2330
2431 # Initialize the configuration dictionary
Original file line number Diff line number Diff line change @@ -15,9 +15,16 @@ def _es_config() -> Dict[str, Any]:
1515 scheme = "https" if use_ssl else "http"
1616
1717 # Configure the hosts parameter with the correct scheme
18+ es_hosts = os .getenv ("ES_HOST" , "localhost" ).strip () # Default to localhost if ES_HOST is not set
19+ es_port = os .getenv ("ES_PORT" , "9200" ) # Default to 9200 if ES_PORT is not set
20+
21+ # Validate ES_HOST
22+ if not es_hosts :
23+ raise ValueError ("ES_HOST environment variable is empty or invalid." )
24+
1825 hosts = [
19- f"{ scheme } ://{ host .strip ()} :{ os . getenv ( 'ES_PORT' ) } "
20- for host in os . getenv ( "ES_HOST" ) .split ("," )
26+ f"{ scheme } ://{ host .strip ()} :{ es_port } "
27+ for host in es_hosts .split ("," )
2128 ]
2229
2330 # Initialize the configuration dictionary
You can’t perform that action at this time.
0 commit comments