Skip to content

Commit

Permalink
fix: fix no argument build_args_envs of api normalizer (#49)
Browse files Browse the repository at this point in the history
fix no argument build_args_envs of api normalizer
  • Loading branch information
floralatin committed Jul 27, 2022
1 parent 34ed025 commit 684c8f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions normalizer/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def normalize(
docker_file=dockerfile_path,
build_args={'JINA_VERSION': f'{jina_version}'},
)
if len(build_args_envs.keys()):
if build_args_envs and len(build_args_envs.keys()):
dockerfile.insert_build_args_envs(build_args_envs)
# if dockerfile.is_multistage():
# # Don't support multi-stage Dockerfie Optimization
Expand All @@ -608,7 +608,7 @@ def normalize(
# if len(base_images) > 0:
# logger.debug(f'=> use base image: {base_images}')
# dockerfile.baseimage = base_images.pop()
if len(build_args_envs.keys()):
if build_args_envs and len(build_args_envs.keys()):
dockerfile.insert_build_args_envs(build_args_envs)

dockerfile.add_work_dir()
Expand Down
10 changes: 10 additions & 0 deletions tests/cases/executor_2/Dockerfile.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file is automatically generated by Jina executor normalizer plugin.
# It is not intended for manual editing.

FROM jinaai/jina:2-py37-perf

# setup the workspace
COPY . /workspace
WORKDIR /workspace

ENTRYPOINT ["jina", "executor", "--uses", "config.yml"]
4 changes: 4 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def test_get_executor_args(package_path, expected_path):
'TOKEN': 'ghp_Nwh9o70GDSzs'
}
),
(
Path(__file__).parent / 'cases' / 'executor_2',
None
),
],
)
def test_compare_dockerfile_env_vars(package_path, build_args_envs):
Expand Down

0 comments on commit 684c8f6

Please sign in to comment.