Skip to content

Commit

Permalink
Merge pull request #308 from MITLibraries/expand-local-hosts
Browse files Browse the repository at this point in the history
Support 'opensearch' as local host variation
  • Loading branch information
ghukill authored Jan 23, 2024
2 parents 74a2377 + d6fcce5 commit 47f230a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions tests/test_opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ def test_configure_opensearch_client_for_localhost():
assert str(result) == "<OpenSearch([{'host': 'localhost', 'port': '9200'}])>"


def test_configure_opensearch_client_for_local_opensearch_host():
result = tim_os.configure_opensearch_client("opensearch")
assert str(result) == "<OpenSearch([{'host': 'opensearch', 'port': '9200'}])>"


@mock.patch("boto3.session.Session")
def test_configure_opensearch_client_for_aws(mocked_boto3_session): # noqa
result = tim_os.configure_opensearch_client("fake-dev.us-east-1.es.amazonaws.com")
Expand Down
2 changes: 1 addition & 1 deletion tim/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def configure_opensearch_client(url: str) -> OpenSearch:
Includes the appropriate AWS credentials configuration if the URL is not localhost.
"""
logger.info("OpenSearch request configurations: %s", REQUEST_CONFIG)
if url == "localhost":
if url in ["localhost", "opensearch"]:
return OpenSearch(
hosts=[{"host": url, "port": "9200"}],
http_auth=("admin", "admin"),
Expand Down

0 comments on commit 47f230a

Please sign in to comment.