Repository navigation
fix(docker/v2): expand global ARG references when resolving the base image - #7203
Merged
caarlos0 merged 3 commits intoOct 21, 2026
Merged
Conversation
…image
A global ARG default can reference a previously declared ARG, e.g.
ARG ALPINE_VERSION=3.20
ARG BASE=alpine:${ALPINE_VERSION}
FROM ${BASE}
parseBaseImage stored the raw default, so .BaseImage became
"alpine:${ALPINE_VERSION}" and digest resolution failed. Build-arg
overrides of the referenced ARG were also ignored, because only ARGs
named directly in FROM lines were considered.
Expand ARG defaults with the ARGs declared before them, and consider
ARGs referenced by global ARG defaults when collecting overrides.
Assisted-by: Claude
Signed-off-by: Guillaume Marty <[email protected]>
caarlos0
previously requested changes
Oct 21, 2026
caarlos0
left a comment
Member
There was a problem hiding this comment.
Copilot, on behalf of Carlos.
One blocking regression found. Both independent read-only checks are complete.
Validation limits: source inspection only; no local builds or tests were run. The reported PR checks show only WIP passing, not test results.
Address PR goreleaser#7203 feedback about unrelated global ARG defaults forcing BaseImage and BaseImageDigest templates to render before those fields exist. Trace defaults backward from FROM references and cover unrelated defaults and transitive overrides. Co-authored-by: Copilot <[email protected]> Copilot-Session: 812fd81f-41a3-4ce7-8fe0-7d06c880c5d0 Signed-off-by: Carlos Alexandro Becker <[email protected]>
caarlos0
dismissed
their stale review
October 21, 2026 02:13
Superseded: ec3251c fixes the reported regression, adds coverage, and passes the Docker v2 package tests. The review thread is resolved.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7203 +/- ##
=======================================
Coverage 91.61% 91.61%
=======================================
Files 192 192
Lines 15984 16001 +17
=======================================
+ Hits 14643 14660 +17
Misses 1341 1341 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A global
ARGdefault can reference a previously declared globalARG:parseBaseImagestored the raw default, so.BaseImagebecamealpine:${ALPINE_VERSION}. Theorg.opencontainers.image.base.nameannotation then got the unexpanded string, and digest resolution failed. Abuild_argsoverride of the referenced ARG (ALPINE_VERSION) was also ignored, becausebaseImageBuildArgsonly collected ARGs named directly inFROMlines.This PR changes two things:
This is related to #6923 (direct overrides, fixed in #7095). This PR covers the nested case.
Tests: I added
testdata/dockerfiles/arg-references-argandTestMakeArgsWithBaseImageNestedBuildArgOverride. Without the fix both fail:actual: "alpine:${ALPINE_VERSION}"base.name=${ALPINE_REF}With the fix,
go test ./internal/pipe/docker/v2/passes.AI disclosure: this change was prepared with the help of an AI assistant (Claude). The commit carries
Assisted-by: Claude. I reviewed and tested the change.🤖 Generated with Claude Code