From 0bc00e003675e960ff923f0bc847c6f1aee81c6a Mon Sep 17 00:00:00 2001
From: Liz Rice <liz@lizrice.com>
Date: Wed, 30 Aug 2017 17:48:12 +0100
Subject: [PATCH] Slightly more robust looking for running executables

---
 cmd/util.go | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/cmd/util.go b/cmd/util.go
index 10a13c2..bd12398 100644
--- a/cmd/util.go
+++ b/cmd/util.go
@@ -87,7 +87,19 @@ func verifyBin(bin string, psFunc func(string) string) bool {
 	proc := strings.Fields(bin)[0]
 	out := psFunc(proc)
 
-	return strings.Contains(out, bin)
+	if !strings.Contains(out, bin) {
+		return false
+	}
+
+	// Make sure we're not just matching on a partial word (e.g. if we're looking for apiserver, don't match on kube-apiserver)
+	// This will give a false positive for matching "one two" against "zero one two-x" but it will do for now
+	for _, f := range strings.Fields(out) {
+		if f == proc {
+			return true
+		}
+	}
+
+	return false
 }
 
 // findExecutable looks through a list of possible executable names and finds the first one that's running
-- 
GitLab