Skip to content

Commit 47f230a

Browse files
authored
Merge pull request #308 from MITLibraries/expand-local-hosts
Support 'opensearch' as local host variation
2 parents 74a2377 + d6fcce5 commit 47f230a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

tests/test_opensearch.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ def test_configure_opensearch_client_for_localhost():
2525
assert str(result) == "<OpenSearch([{'host': 'localhost', 'port': '9200'}])>"
2626

2727

28+
def test_configure_opensearch_client_for_local_opensearch_host():
29+
result = tim_os.configure_opensearch_client("opensearch")
30+
assert str(result) == "<OpenSearch([{'host': 'opensearch', 'port': '9200'}])>"
31+
32+
2833
@mock.patch("boto3.session.Session")
2934
def test_configure_opensearch_client_for_aws(mocked_boto3_session): # noqa
3035
result = tim_os.configure_opensearch_client("fake-dev.us-east-1.es.amazonaws.com")

tim/opensearch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def configure_opensearch_client(url: str) -> OpenSearch:
3434
Includes the appropriate AWS credentials configuration if the URL is not localhost.
3535
"""
3636
logger.info("OpenSearch request configurations: %s", REQUEST_CONFIG)
37-
if url == "localhost":
37+
if url in ["localhost", "opensearch"]:
3838
return OpenSearch(
3939
hosts=[{"host": url, "port": "9200"}],
4040
http_auth=("admin", "admin"),

0 commit comments

Comments
 (0)