Skip to content

Commit

Permalink
chore: update log (aws#7371)
Browse files Browse the repository at this point in the history
* chore: update log

* fix log

* black reformat

* update test
  • Loading branch information
hawflau authored Aug 17, 2024
1 parent 0d3d53b commit 89a29b8
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion samcli/lib/build/app_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def _build_lambda_image(self, function_name: str, metadata: Dict, architecture:
docker_tag = "-".join([docker_tag, docker_build_args["SAM_BUILD_MODE"]])

if isinstance(docker_build_args, dict):
LOG.info("Setting DockerBuildArgs: %s for %s function", docker_build_args, function_name)
LOG.info("Setting DockerBuildArgs for %s function", function_name)

build_args = {
"path": str(docker_context_dir),
Expand Down
6 changes: 5 additions & 1 deletion samcli/lib/build/build_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,10 +648,14 @@ def _validate_functions(self) -> None:
raise InvalidBuildGraphException("Build definition doesn't have any function definition to build")

def __str__(self) -> str:
metadata = self.metadata.copy()
if "DockerBuildArgs" in metadata:
del metadata["DockerBuildArgs"]

return (
"BuildDefinition("
f"{self.runtime}, {self.codeuri}, {self.packagetype}, {self.source_hash}, "
f"{self.uuid}, {self.metadata}, {self.env_vars}, {self.architecture}, "
f"{self.uuid}, {metadata}, {self.env_vars}, {self.architecture}, "
f"{[f.functionname for f in self.functions]})"
)

Expand Down
3 changes: 1 addition & 2 deletions samcli/lib/build/build_strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ def build_single_function_definition(self, build_definition: FunctionBuildDefini
"""
function_build_results = {}
LOG.info(
"Building codeuri: %s runtime: %s metadata: %s architecture: %s functions: %s",
"Building codeuri: %s runtime: %s architecture: %s functions: %s",
build_definition.codeuri,
build_definition.runtime,
build_definition.metadata,
build_definition.architecture,
build_definition.get_resource_full_paths(),
)
Expand Down
10 changes: 10 additions & 0 deletions samcli/lib/providers/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,16 @@ def architecture(self) -> str:
)
return str(arch_list[0])

def __str__(self) -> str:
metadata = None if not self.metadata else self.metadata.copy()
if metadata and "DockerBuildArgs" in metadata:
del metadata["DockerBuildArgs"]

copy = self._asdict()
if metadata:
copy["metadata"] = metadata
return f"Function({copy})"


class ResourcesToBuildCollector:
def __init__(self) -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/buildcmd/build_integ_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ def _verify_process_code_and_output(self, command_result):
# check HelloWorld and HelloMars functions are built in the same build
self.assertRegex(
command_result.stderr.decode("utf-8"),
"Building codeuri: .* runtime: .* metadata: .* functions: " "HelloWorldFunction, HelloMarsFunction",
"Building codeuri: .* runtime: .* functions: " "HelloWorldFunction, HelloMarsFunction",
)


Expand Down Expand Up @@ -959,7 +959,7 @@ def _verify_process_code_and_output(self, command_result, function_full_paths):
for function_full_path in function_full_paths:
self.assertRegex(
command_result.stderr.decode("utf-8"),
f"Building codeuri: .* runtime: .* metadata: .* functions: .*{function_full_path}.*",
f"Building codeuri: .* runtime: .* functions: .*{function_full_path}.*",
)

def _verify_invoke_built_functions(self, template_path, overrides, function_and_expected):
Expand Down Expand Up @@ -1004,7 +1004,7 @@ def _verify_process_code_and_output(self, command_result, function_full_paths, l
for function_full_path in function_full_paths:
self.assertRegex(
command_result.stderr.decode("utf-8"),
f"Building codeuri: .* runtime: .* metadata: .* functions:.*{function_full_path}.*",
f"Building codeuri: .* runtime: .* functions:.*{function_full_path}.*",
)
self.assertIn(
f"Building layer '{layer_full_path}'",
Expand Down

0 comments on commit 89a29b8

Please sign in to comment.