pack icon indicating copy to clipboard operation
pack copied to clipboard

Separate `TrustedBuilders` from `SuggestedBuilders`

Open runesoerensen opened this issue 7 months ago • 1 comments

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 KnownBuilder struct with separate TrustedBuilders (flat []string for trust decisions) and SuggestedBuilder / SuggestedBuilders (display metadata for builder suggest)
  • Add invariant test ensuring every suggested builder is also a trusted builder
  • Remove Trusted and Suggested boolean fields that previously required filtering

Output

N/A - no user-facing output changes.

Documentation

  • Should this change be documented?
    • [x] No

Related

Resolves #2574

runesoerensen avatar Apr 15 '26 04:04 runesoerensen

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 in TrustedBuilders, 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=1
  • go test ./pkg/client -run 'TestBuild' -count=1

Both pass currently, so this looks like a coverage gap rather than an existing failing test.

TIR44 avatar May 31 '26 11:05 TIR44