Separate `TrustedBuilders` from `SuggestedBuilders`
Summary
Note: This draft PR builds on unmerged changes introduced in #2573 - see https://github.com/runesoerensen/pack/compare/runesoerensen/consolidate-trusted-builder-logic...runesoerensen:pack:runesoerensen/separate-trusted-suggested-builders to inspect only the commits introduced since that branch.
Separate trust decisions from display metadata by splitting KnownBuilder into dedicated data structures for each concern.
- Replace
KnownBuilderstruct with separateTrustedBuilders(flat[]stringfor trust decisions) andSuggestedBuilder/SuggestedBuilders(display metadata forbuilder suggest) - Add invariant test ensuring every suggested builder is also a trusted builder
- Remove
TrustedandSuggestedboolean fields that previously required filtering
Output
N/A - no user-facing output changes.
Documentation
- Should this change be documented?
- [x] No
Related
Resolves #2574
I took a look at this draft while checking the #2574 / #2572 trust split path. One edge to keep before this leaves draft: after the split, IsKnownTrustedBuilder() is exact-match again (paketobuildpacks/builder-jammy-base:latest is expected to return false in the current test), but pkg/client/build.go still defaults opts.TrustBuilder = builder.IsKnownTrustedBuilder.
That means the command path is covered by IsTrustedBuilder(), but the client default build path can still miss tag variants of tagless trusted builders. That seems to preserve part of the #2572 inconsistency after the refactor.
A narrow fix would be either:
- keep
IsKnownTrustedBuilder()reference-aware for entries inTrustedBuilders, or - add a separate reference-aware helper for the default client trust checker and use that from
pkg/client/build.go.
Suggested regression coverage: a client-level build test where BuildOptions.Builder is paketobuildpacks/builder-jammy-base:latest and TrustBuilder is left nil, asserting the default trusted-builder path is used.
I ran these against the draft branch:
go test ./internal/builder -run TestTrustedBuilder -count=1go test ./pkg/client -run 'TestBuild' -count=1
Both pass currently, so this looks like a coverage gap rather than an existing failing test.