Skip to content

Commit 271f26e

Browse files
authored
Merge branch 'main' into add-auto-remove-container-option
2 parents 4324b79 + 6dc32ad commit 271f26e

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ class TestKinesis(unittest.TestCase):
4343
```
4444

4545
## Change Log
46-
* 1.0.0: Repository URL fixed
46+
* 1.0.2: LocalStack Pro image set as default
47+
* 1.0.1: Repository URL fixed
4748
* 1.0.0: Initial version

localstack_utils/container.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import docker
44
from time import sleep
55

6-
LOCALSTACK_COMMUNITY_IMAGE_NAME = "localstack/localstack"
7-
LOCALSTACK_PRO_IMAGE_NAME = "localstack/localstack-pro"
6+
LOCALSTACK_IMAGE_NAME = "localstack/localstack-pro"
87
LATEST_TAG = "latest"
98

109
MAX_PORT_CONNECTION_ATTEMPTS = 10
@@ -24,25 +23,21 @@
2423
class Container:
2524
@staticmethod
2625
def create_localstack_container(
27-
pull_new_image: bool,
28-
image_name: str = None,
26+
*args,
27+
pull_new_image: bool = False,
28+
image_name: str = LOCALSTACK_IMAGE_NAME,
2929
image_tag: str = LATEST_TAG,
3030
gateway_listen: str = "0.0.0.0:4566",
31-
environment_variables: dict = None,
32-
bind_ports: dict = None,
33-
pro: bool = False,
3431
auto_remove: bool = False,
32+
environment_variables: dict | None = None,
33+
bind_ports: dict | None = None,
34+
**kwargs,
3535
):
3636
environment_variables = environment_variables or {}
3737
environment_variables["GATEWAY_LISTEN"] = gateway_listen
3838

39-
image_name_or_default = image_name or (
40-
LOCALSTACK_PRO_IMAGE_NAME if pro else LOCALSTACK_COMMUNITY_IMAGE_NAME
41-
)
4239
image_exists = (
43-
True
44-
if len(DOCKER_CLIENT.images.list(name=image_name_or_default))
45-
else False
40+
True if len(DOCKER_CLIENT.images.list(name=image_name)) else False
4641
)
4742

4843
bind_ports = bind_ports or {}
@@ -51,10 +46,10 @@ def create_localstack_container(
5146

5247
if pull_new_image or not image_exists:
5348
logging.info("Pulling latest image")
54-
DOCKER_CLIENT.images.pull(image_name_or_default, image_tag)
49+
DOCKER_CLIENT.images.pull(image_name, image_tag)
5550

5651
return DOCKER_CLIENT.containers.run(
57-
image_name_or_default,
52+
image_name,
5853
ports=bind_ports,
5954
environment=environment_variables,
6055
auto_remove=auto_remove,

0 commit comments

Comments
 (0)