From 957cabba2d1485260e7fcda208d8c6a6682435b4 Mon Sep 17 00:00:00 2001 From: Sergey Ponomarev Date: Tue, 17 Nov 2020 12:06:34 +0200 Subject: [PATCH] docker.go: watchEvents() optimize actionName extraction Split(e.Action, ":") creates and array but we can avoid this. --- connector/docker.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/connector/docker.go b/connector/docker.go index 8820a60..22f5758 100644 --- a/connector/docker.go +++ b/connector/docker.go @@ -68,7 +68,13 @@ func (cm *Docker) watchEvents() { continue } - actionName := strings.Split(e.Action, ":")[0] + actionName := e.Action + // Action may have additional param: "exec_create: redis-cli ping" or "health_status: healthy" + // We need to strip to have only action name + sepIdx := strings.Index(actionName, ": ") + if sepIdx != -1 { + actionName = actionName[:sepIdx] + } switch actionName { case "start", "die", "pause", "unpause", "health_status":