buildx
buildx copied to clipboard
bake: add targets.current support
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=1go test ./bake/hclparser/... -count=1