Repository navigation
fix: compare repository names when checking the default builder in pack build - #2736
jjbustamante merged 4 commits into
Conversation
…ck build isForbiddenTag compared the repository of the image being built with the registry of the configured default builder, so the check never matched. As a result, pack build accepted an image name that matches the default builder (for example when --builder or project.toml selects another builder) and could overwrite the default builder image. Compare the repository of both references, as the other checks in the function already do. Signed-off-by: Raphael Fakhri <153192858+RaphaelFakhri@users.noreply.github.com>
ToniAdreal
left a comment
There was a problem hiding this comment.
I independently verified this against main (f250204) from a fresh checkout (Go 1.27.3, linux/amd64): with only the new test applied, TestBuildCommand fails exactly on the new spec (81 passed / 1 failed); with the one-line change applied, the full suite is green (82 passed / 0 failed).
The fix also matches the four sibling checks in isForbiddenTag, which all compare RepositoryStr() on both sides (build.go:440/450/461/471), so this looks like the intended comparison rather than a new semantic. The new test pins the reported scenario (default builder some-org/default-builder:latest, image some-org/default-builder:test) and asserts the exact error string.
Looks good to me.
jjbustamante
left a comment
There was a problem hiding this comment.
Thnaks for this @RaphaelFakhri
Summary
isForbiddenTagcompared the repository of the image being built with the registry of the configured default builder (RegistryStr()), so the default builder check never matched.pack buildtherefore accepted an image name equal to the default builder when--builderorproject.tomlselected another builder, and the build overwrote the default builder image.This change compares
RepositoryStr()on both sides, as the builder, lifecycle and trusted builder checks in the same function already do, and adds a test for the default builder case.Output
Before
After
Documentation
Related
Resolves #2735