buildx icon indicating copy to clipboard operation
buildx copied to clipboard

bake: add targets.current support

Open cjc0013 opened this issue 5 months ago • 0 comments

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

cjc0013 avatar Jun 12 '26 20:06 cjc0013