refactor(hooks): simplify package while preserving features#2522
Merged
dgageot merged 1 commit intodocker:mainfrom Apr 27, 2026
Merged
Conversation
Trim ~30% of non-test code in pkg/hooks while keeping every public API
and behavioral contract intact (all hooks tests, runtime hook-wiring
tests, go vet, and golangci-lint pass).
- Unify the Executor event lookup: remove the eventHooks{flat,
matchers} split and the selectHooks helper. Every event now compiles
to a single []matcher slice; flat events become one matcher with an
empty pattern, so dispatch is one filter loop.
- Inline executeHooks + aggregateResults + dedup into Dispatch.
executeHook's 5-return-value signature becomes runHook returning a
hookResult. aggregate uses a clean switch over per-hook outcomes.
- Replace the contextEvents switch with a small map[EventType]bool to
decide which events route plain stdout into AdditionalContext.
- Merge builtin.go into handler.go: registry, factories, and handlers
now live in one file. HookTypeBuiltin moves into types.go alongside
HookTypeCommand.
- Compact Config.IsEmpty, convertHooks/convertMatchers, and the
builtins Register (single map iteration). Extract a small
turnStartContext helper to remove duplicated Output boilerplate.
- Trim verbose multi-paragraph doc blocks across all files while
keeping concise but informative godoc on public APIs.
Assisted-By: docker-agent
rumpl
approved these changes
Apr 27, 2026
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.
Trim ~30% of non-test code in
pkg/hookswhile keeping every public APIand behavioral contract intact. All hooks tests, runtime hook-wiring
tests,
go vet, andgolangci-lintpass.Changes
Executorevent lookup: remove theeventHooks{flat, matchers}split and theselectHookshelper. Every event now compilesto a single
[]matcherslice; flat events become one matcher with anempty pattern, so dispatch is one filter loop.
executeHooks+aggregateResults+ dedup intoDispatch.The 5-return-value
executeHookbecomesrunHookreturning ahookResult.aggregateuses a cleanswitchover per-hook outcomes.contextEventsswitch with a smallmap[EventType]boolto decide which events route plain stdout intoAdditionalContext.builtin.gointohandler.go: registry, factories, andhandlers now live in one file.
HookTypeBuiltinmoves intotypes.goalongside
HookTypeCommand.Config.IsEmpty,convertHooks/convertMatchers, and thebuiltins
Register(single map iteration). Extract a smallturnStartContexthelper to remove duplicatedOutputboilerplate.keeping concise but informative godoc on public APIs.
Diff stats
7 files changed, 404 insertions(+), 766 deletions(-)types.goexecutor.gohandler.gobuiltin.go)builtin.goconfig.gobuiltins/builtins.go