Skip to content

Commit 064f092

Browse files
committed
patch botocore to skip adding data- host prefixes to endpoint URLs; remove six dependency
1 parent 0d92805 commit 064f092

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# LocalStack Python Client Change Log
22

3+
* v1.33: Patch botocore to skip adding `data-` host prefixes to endpoint URLs; remove six dependency
34
* v1.32: Add endpoint for KinesisAnalyticsV2
45
* v1.31: Revert mapping for OpenSearch (drop support for `OPENSEARCH_ENDPOINT_STRATEGY=off`)
56
* v1.30: Allow legacy port handling for OpenSearch (to support `OPENSEARCH_ENDPOINT_STRATEGY=off`)

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
VENV_DIR ?= .venv
22
VENV_RUN = . $(VENV_DIR)/bin/activate
33
PIP_CMD ?= pip
4+
BUILD_DIR ?= dist
45

56
usage: ## Show this help
67
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
@@ -13,7 +14,7 @@ install: ## Install dependencies in local virtualenv folder
1314

1415
publish: ## Publish the library to the central PyPi repository
1516
# build and upload archive
16-
($(VENV_RUN) && ./setup.py sdist upload)
17+
($(VENV_RUN); ./setup.py sdist && twine upload $(BUILD_DIR)/*.tar.gz)
1718

1819
test: ## Run automated tests
1920
($(VENV_RUN); test `which localstack` || pip install .[test]) && \

localstack_client/config.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import os
22
import json
3-
from six.moves.urllib.parse import urlparse
3+
from botocore.serialize import Serializer
44

55
# central entrypoint port for all LocalStack API endpoints
6+
from urllib.parse import urlparse
7+
68
EDGE_PORT = int(os.environ.get('EDGE_PORT') or 4566)
79

810
# NOTE: The endpoints below will soon become deprecated/removed, as the default in the
@@ -140,3 +142,17 @@ def get_service_ports():
140142
for service, url in endpoints.items():
141143
result[service] = urlparse(url).port
142144
return result
145+
146+
147+
def patch_expand_host_prefix():
148+
"""Apply a patch to botocore, to skip adding `data-` host prefixes to endpoint URLs"""
149+
150+
def _expand_host_prefix(self, parameters, operation_model, *args, **kwargs):
151+
result = _expand_host_prefix_orig(self, parameters, operation_model, *args, **kwargs)
152+
# skip adding data- prefix, to avoid making requests to http://data-localhost:4566
153+
if operation_model.name == "DiscoverInstances" and result == "data-":
154+
return None
155+
return result
156+
157+
_expand_host_prefix_orig = Serializer._expand_host_prefix
158+
Serializer._expand_host_prefix = _expand_host_prefix

setup.cfg

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = localstack-client
3-
version = 1.32
3+
version = 1.33
44
url = https://github.com/localstack/localstack-python-client
55
author = LocalStack Team
66
author_email = info@localstack.cloud
@@ -26,7 +26,6 @@ packages =
2626

2727
install_requires =
2828
boto3
29-
six
3029

3130
[options.extras_require]
3231
# Dependencies to run the tests

0 commit comments

Comments
 (0)