MCPcopy Index your code
hub / github.com/docker/cli / pluginMatch

Function pluginMatch

cli-plugins/manager/hooks.go:159–173  ·  view source on GitHub ↗

pluginMatch takes a plugin configuration and a string representing the command being executed (such as 'image ls' – the root 'docker' is omitted) and, if the configuration includes a hook for the invoked command, returns the configured hook string. Plugins can declare two types of hooks in their co

(pluginCfg map[string]string, subCmd string, cmdErrorMessage string)

Source from the content-addressed store, hash-verified

157// - "hooks": fires on every command invocation (success or failure)
158// - "error-hooks": fires only when a command fails (cmdErrorMessage is non-empty)
159func pluginMatch(pluginCfg map[string]string, subCmd string, cmdErrorMessage string) (string, bool) {
160 // Check "hooks" first — these always fire regardless of command outcome.
161 if match, ok := matchHookConfig(pluginCfg["hooks"], subCmd); ok {
162 return match, true
163 }
164
165 // Check "error-hooks" — these only fire when there was an error.
166 if cmdErrorMessage != "" {
167 if match, ok := matchHookConfig(pluginCfg["error-hooks"], subCmd); ok {
168 return match, true
169 }
170 }
171
172 return "", false
173}
174
175// matchHookConfig checks if a comma-separated hook configuration string
176// contains a prefix match for the given subcommand.

Callers 2

TestPluginMatchFunction · 0.85
invokeAndCollectHooksFunction · 0.85

Calls 1

matchHookConfigFunction · 0.85

Tested by 1

TestPluginMatchFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…