Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Allow passing environment variables in to container #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pytest_localstack/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ class LocalstackSession(RunningSession):
container. Defaults to a randomly generated id.
use_ssl (bool, optional): If True use SSL to connect to Localstack.
Default is False.
container_env (dict, optional): A dictionary of environment variables
which will be set in the Localstack container. see
https://docs.localstack.cloud/references/configuration/ for useful
settings.
**kwargs: Additional kwargs will be stored in a `kwargs` attribute
in case test resource factories want to access them.

Expand All @@ -249,6 +253,7 @@ def __init__(
container_name=None,
use_ssl=False,
hostname=None,
container_env=None,
**kwargs,
):
self._container = None
Expand All @@ -274,6 +279,7 @@ def __init__(
self.container_log_level = container_log_level
self.localstack_version = localstack_version
self.container_name = container_name or generate_container_name()
self.container_env = container_env or {}

def start(self, timeout=60):
"""Start the Localstack container.
Expand Down Expand Up @@ -319,6 +325,7 @@ def start(self, timeout=60):
"KINESIS_ERROR_PROBABILITY": kinesis_error_probability,
"DYNAMODB_ERROR_PROBABILITY": dynamodb_error_probability,
"USE_SSL": use_ssl,
**self.container_env,
},
ports={port: None for port in self.services.values()},
)
Expand Down