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)
| 157 | // - "hooks": fires on every command invocation (success or failure) |
| 158 | // - "error-hooks": fires only when a command fails (cmdErrorMessage is non-empty) |
| 159 | func 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. |
searching dependent graphs…