Skip to content

Commit

Permalink
Add description_of_origin for Docker address parsing (#15814)
Browse files Browse the repository at this point in the history
Last part of #14468.

[ci skip-rust]
[ci skip-build-wheels]
  • Loading branch information
Eric-Arellano authored Jun 15, 2022
1 parent 2de1dac commit 19fe4e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/python/pants/backend/docker/util_rules/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pants.engine.rules import Get, collect_rules, rule
from pants.engine.target import InjectDependenciesRequest, InjectedDependencies
from pants.engine.unions import UnionRule
from pants.util.strutil import softwrap


class InjectDockerDependencies(InjectDependenciesRequest):
Expand All @@ -33,7 +34,12 @@ async def inject_docker_dependencies(
UnparsedAddressInputs(
(v for v in dockerfile_info.from_image_build_args.to_dict().values() if v),
owning_address=dockerfile_info.address,
description_of_origin="TODO(#14468)",
description_of_origin=softwrap(
f"""
the FROM arguments from the file {dockerfile_info.source}
from the target {dockerfile_info.address}
"""
),
),
)
)
Expand Down
14 changes: 11 additions & 3 deletions src/python/pants/backend/docker/util_rules/docker_build_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
TransitiveTargetsRequest,
)
from pants.engine.unions import UnionRule
from pants.util.strutil import softwrap

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -237,8 +238,10 @@ async def create_docker_build_context(
Get(BuiltPackage, PackageFieldSet, field_set)
for field_set in embedded_pkgs_per_target.field_sets
# Exclude docker images, unless build_upstream_images is true.
if request.build_upstream_images
or not isinstance(getattr(field_set, "source", None), DockerImageSourceField)
if (
request.build_upstream_images
or not isinstance(getattr(field_set, "source", None), DockerImageSourceField)
)
)

if request.build_upstream_images:
Expand Down Expand Up @@ -283,7 +286,12 @@ async def create_docker_build_context(
UnparsedAddressInputs(
dockerfile_build_args.values(),
owning_address=dockerfile_info.address,
description_of_origin="TODO(#14468)",
description_of_origin=softwrap(
f"""
the FROM arguments from the file {dockerfile_info.source}
from the target {dockerfile_info.address}
"""
),
),
)
# Map those addresses to the corresponding built image ref (tag).
Expand Down

0 comments on commit 19fe4e3

Please sign in to comment.