Skip to content

Commit 06250fa

Browse files
authored
allow sourcing docker images from custom registry (#129)
* update to allow sourcing from internal registry, if one is configured, by adding prefix to image name - leverages existing DOCKER_GLOBAL_IMAGE_PREFIX config * adding ability to specify image name, including tag, to allow usage when latest tag is blocked
1 parent f186d3e commit 06250fa

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

utils/localstack_extensions/utils/docker.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,12 @@ def __init__(
103103
http2_ports: list[int] | None = None,
104104
tcp_ports: list[int] | None = None,
105105
):
106-
self.image_name = image_name
106+
try:
107+
from localstack.pro.core.utils.container.registry_strategies import CustomizableRegistryStrategy
108+
self.image_name = CustomizableRegistryStrategy().resolve(image_name)
109+
except ImportError:
110+
self.image_name = image_name
111+
107112
if not container_ports:
108113
raise ValueError("container_ports is required")
109114
self.container_ports = container_ports

utils/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "localstack-extensions-utils"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
description = "Utility library for LocalStack Extensions"
99
readme = {file = "README.md", content-type = "text/markdown; charset=UTF-8"}
1010
requires-python = ">=3.10"

wiremock/localstack_wiremock/extension.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
ENV_WIREMOCK_API_TOKEN = "WIREMOCK_API_TOKEN"
1515
# Host path to directory containing .wiremock/ (required for runner mode)
1616
ENV_WIREMOCK_CONFIG_DIR = "WIREMOCK_CONFIG_DIR"
17+
# Override the OSS image (default: wiremock/wiremock); accepts full ref with optional tag
18+
ENV_WIREMOCK_IMAGE = "WIREMOCK_IMAGE"
19+
# Override the runner image (default: wiremock/wiremock-runner); accepts full ref with optional tag
20+
ENV_WIREMOCK_IMAGE_RUNNER = "WIREMOCK_IMAGE_RUNNER"
1721

1822
SERVICE_PORT = 8080 # Mock API port
1923
ADMIN_PORT = 9999 # Admin interface port (runner mode)
@@ -29,7 +33,7 @@ class WireMockExtension(ProxiedDockerContainerExtension):
2933

3034
def __init__(self):
3135
env_vars = {}
32-
image_name = self.DOCKER_IMAGE
36+
image_name = os.getenv(ENV_WIREMOCK_IMAGE) or self.DOCKER_IMAGE
3337
volumes = None
3438
container_ports = [SERVICE_PORT]
3539
health_check_path = "/__admin/health"
@@ -41,7 +45,7 @@ def __init__(self):
4145
env_vars["WMC_ADMIN_PORT"] = str(ADMIN_PORT)
4246
env_vars["WMC_API_TOKEN"] = api_token
4347
env_vars["WMC_RUNNER_ENABLED"] = "true"
44-
image_name = self.DOCKER_IMAGE_RUNNER
48+
image_name = os.getenv(ENV_WIREMOCK_IMAGE_RUNNER) or self.DOCKER_IMAGE_RUNNER
4549
container_ports = [SERVICE_PORT, ADMIN_PORT]
4650
health_check_path = "/__/health"
4751
health_check_retries = 90

0 commit comments

Comments
 (0)