Merge pull request #5893 from thaJeztah/hooks_optim
small performance optimizations for running hooks
This commit is contained in:
commit
a9e530999e
@ -194,16 +194,16 @@ func (cli *DockerCli) BuildKitEnabled() (bool, error) {
|
|||||||
|
|
||||||
// HooksEnabled returns whether plugin hooks are enabled.
|
// HooksEnabled returns whether plugin hooks are enabled.
|
||||||
func (cli *DockerCli) HooksEnabled() bool {
|
func (cli *DockerCli) HooksEnabled() bool {
|
||||||
// legacy support DOCKER_CLI_HINTS env var
|
// use DOCKER_CLI_HOOKS env var value if set and not empty
|
||||||
if v := os.Getenv("DOCKER_CLI_HINTS"); v != "" {
|
if v := os.Getenv("DOCKER_CLI_HOOKS"); v != "" {
|
||||||
enabled, err := strconv.ParseBool(v)
|
enabled, err := strconv.ParseBool(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return enabled
|
return enabled
|
||||||
}
|
}
|
||||||
// use DOCKER_CLI_HOOKS env var value if set and not empty
|
// legacy support DOCKER_CLI_HINTS env var
|
||||||
if v := os.Getenv("DOCKER_CLI_HOOKS"); v != "" {
|
if v := os.Getenv("DOCKER_CLI_HINTS"); v != "" {
|
||||||
enabled, err := strconv.ParseBool(v)
|
enabled, err := strconv.ParseBool(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
@ -446,7 +446,7 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
|
|||||||
if err != nil || pluginmanager.IsPluginCommand(ccmd) {
|
if err != nil || pluginmanager.IsPluginCommand(ccmd) {
|
||||||
err := tryPluginRun(ctx, dockerCli, cmd, args[0], envs)
|
err := tryPluginRun(ctx, dockerCli, cmd, args[0], envs)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if dockerCli.HooksEnabled() && dockerCli.Out().IsTerminal() && ccmd != nil {
|
if ccmd != nil && dockerCli.Out().IsTerminal() && dockerCli.HooksEnabled() {
|
||||||
pluginmanager.RunPluginHooks(ctx, dockerCli, cmd, ccmd, args)
|
pluginmanager.RunPluginHooks(ctx, dockerCli, cmd, ccmd, args)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
@ -471,7 +471,7 @@ func runDocker(ctx context.Context, dockerCli *command.DockerCli) error {
|
|||||||
|
|
||||||
// If the command is being executed in an interactive terminal
|
// If the command is being executed in an interactive terminal
|
||||||
// and hook are enabled, run the plugin hooks.
|
// and hook are enabled, run the plugin hooks.
|
||||||
if dockerCli.HooksEnabled() && dockerCli.Out().IsTerminal() && subCommand != nil {
|
if subCommand != nil && dockerCli.Out().IsTerminal() && dockerCli.HooksEnabled() {
|
||||||
var errMessage string
|
var errMessage string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMessage = err.Error()
|
errMessage = err.Error()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user