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

fix: allow --container-env-var-file in sync command #7019

Merged
merged 2 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
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
19 changes: 19 additions & 0 deletions samcli/commands/_utils/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1009,3 +1009,22 @@ def watch_exclude_click_option():
type=SyncWatchExcludeType(),
callback=watch_exclude_option_callback,
)


def container_env_var_file_click_option(cls):
"""
Click option to --container-env-var-file option
"""
return click.option(
"--container-env-var-file",
"-ef",
default=None,
type=click.Path(), # Must be a json file
help="Environment variables json file (e.g., env_vars.json) to be passed to containers.",
cls=cls,
)


@parameterized_option
def container_env_var_file_option(f, cls):
return container_env_var_file_click_option(cls)(f)
mndeveci marked this conversation as resolved.
Show resolved Hide resolved
10 changes: 2 additions & 8 deletions samcli/commands/build/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
build_in_source_option,
cache_dir_option,
cached_option,
container_env_var_file_option,
docker_common_options,
hook_name_click_option,
manifest_option,
Expand Down Expand Up @@ -92,14 +93,7 @@
"\n\n Example: --container-env-var Func1.VAR1=value1 --container-env-var VAR2=value2",
cls=ContainerOptions,
)
@click.option(
"--container-env-var-file",
"-ef",
default=None,
type=click.Path(), # Must be a json file
help="Environment variables json file (e.g., env_vars.json) to be passed to build containers.",
cls=ContainerOptions,
)
@container_env_var_file_option(cls=ContainerOptions)
mndeveci marked this conversation as resolved.
Show resolved Hide resolved
@build_image_option(cls=ContainerOptions)
@click.option(
"--exclude",
Expand Down
6 changes: 6 additions & 0 deletions samcli/commands/sync/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
build_image_option,
build_in_source_option,
capabilities_option,
container_env_var_file_option,
image_repositories_option,
image_repository_option,
kms_key_id_option,
Expand Down Expand Up @@ -158,6 +159,7 @@
help="This option will skip the initial infrastructure deployment if it is not required"
" by comparing the local template with the template deployed in cloud.",
)
@container_env_var_file_option(cls=ContainerOptions)
mndeveci marked this conversation as resolved.
Show resolved Hide resolved
@watch_exclude_option
@stack_name_option(required=True) # pylint: disable=E1120
@base_dir_option
Expand Down Expand Up @@ -210,6 +212,7 @@ def cli(
tags: dict,
metadata: dict,
use_container: bool,
container_env_var_file: Optional[str],
save_params: bool,
config_file: str,
config_env: str,
Expand Down Expand Up @@ -248,6 +251,7 @@ def cli(
tags,
metadata,
use_container,
container_env_var_file,
build_image,
config_file,
config_env,
Expand Down Expand Up @@ -281,6 +285,7 @@ def do_cli(
tags: dict,
metadata: dict,
use_container: bool,
container_env_var_file: Optional[str],
build_image: Optional[Tuple[str]],
config_file: str,
config_env: str,
Expand Down Expand Up @@ -331,6 +336,7 @@ def do_cli(
cache_dir=DEFAULT_CACHE_DIR,
clean=True,
use_container=use_container,
container_env_var_file=container_env_var_file,
cached=True,
parallel=True,
parameter_overrides=parameter_overrides,
Expand Down
Loading
Loading