Skip to content

bake: add targets.current support#3905

Open
cjc0013 wants to merge 1 commit into
docker:masterfrom
cjc0013:pr-lane/buildx-1203-targets-current
Open

bake: add targets.current support#3905
cjc0013 wants to merge 1 commit into
docker:masterfrom
cjc0013:pr-lane/buildx-1203-targets-current

Conversation

@cjc0013

@cjc0013 cjc0013 commented Jun 12, 2026

Copy link
Copy Markdown

Adds targets.current for bake HCL targets so shared target config can refer to the final target currently being resolved.

The value is available while target expressions are decoded, but it is resolved after inheritance and overrides. That keeps the common inherited case working as expected: a _common target inherited by image1 and image2 resolves targets.current to each child target name, not _common and not whichever block happened to parse last. Matrix-derived target names are covered as well.

This also updates the Bake reference docs with the inherited-target use case from the issue.

Closes #1203.

Validation:

  • go test ./bake -count=1
  • go test ./bake/hclparser/... -count=1

Signed-off-by: cjc0013 <cjc0013@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bake-hcl: add mechanism to reference the current target name

1 participant