DockerCLI/cli-plugins/manager
Laura Brehm 9d8320de9d
hooks: include full configured command
Before, for plugin commands, only the plugin name (such as `buildx`)
would be both included as `RootCmd` when passed to the hook plugin,
which isn't enough information for a plugin to decide whether to execute
a hook or not since plugins implement multiple varied commands (`buildx
build`, `buildx prune`, etc.).

This commit changes the hook logic to account for this situation, so
that the the entire configured hook is passed, i.e., if a user has a
hook configured for `buildx imagetools inspect` and the command
`docker buildx imagetools inspect alpine` is called, then the plugin
hooks will be passed `buildx imagetools inspect`.

This logic works for aliased commands too, so whether `docker build ...`
or `docker buildx build` is executed (unless Buildx is disabled) the
hook will be invoked with `buildx build`.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>

hooks: include full match when invoking plugins

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-04-22 13:16:26 +01:00
..
candidate.go remove uses of golang.org/x/sys/execabs 2023-05-26 02:03:45 +02:00
candidate_test.go linting: address else/if/elseif statements found by gocritic 2023-11-20 16:02:16 +01:00
cobra.go plugins: fix encoding for OTEL env var passed to plugin 2024-02-28 12:43:07 -08:00
error.go cli-plugins: Introduce support for hooks 2024-03-22 17:30:18 +00:00
error_test.go cli-plugins/manager: TestPluginError: don't use yaml.Marshal 2022-11-17 13:17:51 +01:00
hooks.go hooks: include full configured command 2024-04-22 13:16:26 +01:00
hooks_test.go hooks: include full configured command 2024-04-22 13:16:26 +01:00
manager.go plugins: set OTEL_RESOURCE_ATTRIBUTES when invoking a plugin 2024-02-28 12:43:05 -08:00
manager_test.go cli-plugins/manager: getPluginDirs: take ConfigFile as argument 2024-01-11 18:15:30 +01:00
manager_unix.go Revert "plugins: run plugin with new process group ID" 2024-01-15 13:30:01 +00:00
manager_windows.go Revert "plugins: run plugin with new process group ID" 2024-01-15 13:30:01 +00:00
metadata.go cli-plugins: Introduce support for hooks 2024-03-22 17:30:18 +00:00
plugin.go hooks: set expected environment when executing 2024-04-17 16:57:44 +01:00
suffix_unix.go remove pre-go1.17 build-tags 2023-05-05 18:23:03 +02:00
suffix_windows.go Check for `.exe` case insensitively 2019-01-30 13:45:26 +00:00