Repository navigation
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Lower-confidence findings (not posted inline)
-
[low] cli-plugins/manager/hooks.go:122 — Fragile nil-slice sentinel replaces explicit boolean 'matched' flag (confidence: unverified low-severity, below threshold)
The old code used a dedicatedok boolreturn value fromtryInvokeHookto distinguish 'plugin not matched' from 'plugin matched and produced messages'. The new code usesif messages == nil { continue }as a sentinel. This is correct today becauseParseTemplatereturns a non-nil slice on success, but the invariant is implicit: ifParseTemplatewere ever changed to return(nil, nil)for an empty template, the loop would silently skip the 'empty hook message' debug log line. The old explicit boolean pattern was more self-documenting. -
[low] cli-plugins/manager/hooks.go:55 — Nil map access in runHooks relies on Go nil-map read semantics (confidence: unverified low-severity, below threshold)
WheninvokeAndCollectHooksreturns early (e.g. context cancelled or no config), it returns a nilmap[hooks.ResponseType][]string. InrunHooks, readingmessages[hooks.GenericMessage]andmessages[hooks.NextSteps]from a nil map is safe in Go (returns zero value), and bothPrintGenericMessagesandPrintNextStepsguard withlen(messages) == 0. This works correctly but relies on a subtle Go nil-map read property; returning an empty map instead of nil would be more explicit.
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
The PR correctly introduces a GenericMessage response type and updates invokeAndCollectHooks to collect both generic and next-step messages into a map[hooks.ResponseType][]string. Nil-map read access in runHooks is safe in Go. The printer correctly sequences generic messages before the next-steps block.
Lower-confidence findings (not posted inline)
- [low]
cli-plugins/manager/hooks.go:119 — Nil-slice sentinel for 'no match' implicitly encodes two states (confidence: weak, unverified)
Allow plugins to return informational messages without the next-steps heading or indentation. Invoke each hook once and render generic messages before the shared next-steps block. Centralize grouping and formatting in PrintMessages using evaluated messages. Keep PrintNextSteps as a deprecated wrapper to preserve existing callers and output. Signed-off-by: Nicolas Beck <nicolas.beck@docker.com>
d794e3b to
1d09f85
Compare
Summary
Plugin hooks can report status and informational messages, but the CLI currently presents all hook output under "What's next:". Add a
GenericMessageresponse type for messages that need no heading or added indentation.Each matching plugin hook is invoked once. Generic messages are collected and printed before the shared
NextStepsblock, whose formatting remains unchanged. Older CLIs ignore the new response type.Example when different plugins return both types:
Validation: the full unit suite passed using the package selection from
make test-unit. Added coverage for mixed plugin responses, one invocation per hook, template expansion, empty output, and invalid responses.