From f589fd58e1b58196a057af4291fff73cba5c61a9 Mon Sep 17 00:00:00 2001
From: Abubakr-Sadik Nii Nai Davis <dwa2pac@gmail.com>
Date: Thu, 13 Jul 2017 01:01:18 +0000
Subject: [PATCH] Add few modifications.

---
 check/check.go |  6 +++---
 cmd/util.go    | 16 ++++++++++++++--
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/check/check.go b/check/check.go
index f005e37..e73c58f 100644
--- a/check/check.go
+++ b/check/check.go
@@ -106,7 +106,7 @@ func (c *Check) Run(verbose bool) {
 		cs[i-1].Stdout, err = cs[i].StdinPipe()
 		errmsgs += handleError(
 			err,
-			fmt.Sprintf("check.Run: Audit %s failed\nfailing command: %s",
+			fmt.Sprintf("failed to run: %s\nfailed command: %s",
 				c.Audit,
 				cs[i].Args,
 			),
@@ -121,7 +121,7 @@ func (c *Check) Run(verbose bool) {
 		err := cs[i].Start()
 		errmsgs += handleError(
 			err,
-			fmt.Sprintf("check.Run: Audit %s failed\nfailing command: %s",
+			fmt.Sprintf("failed to run: %s\nfailed command: %s",
 				c.Audit,
 				cs[i].Args,
 			),
@@ -135,7 +135,7 @@ func (c *Check) Run(verbose bool) {
 		err := cs[i].Wait()
 		errmsgs += handleError(
 			err,
-			fmt.Sprintf("check.Run: Audit %s failed\nfailing command: %s",
+			fmt.Sprintf("failed to run: %s\nfailed command:%s",
 				c.Audit,
 				cs[i].Args,
 			),
diff --git a/cmd/util.go b/cmd/util.go
index 5a01e0d..6a1f790 100644
--- a/cmd/util.go
+++ b/cmd/util.go
@@ -56,7 +56,13 @@ func verifyBin(binPath ...string) []string {
 	// Construct proc name for ps(1)
 	for _, b := range binPath {
 		binList += b + ","
+		_, err := exec.LookPath(b)
+		errmsgs += handleError(
+			err,
+			fmt.Sprintf("%s: command not found in path", b),
+		)
 	}
+
 	binList = strings.Trim(binList, ",")
 
 	// Run ps command
@@ -64,7 +70,7 @@ func verifyBin(binPath ...string) []string {
 	out, err := cmd.Output()
 	errmsgs += handleError(
 		err,
-		fmt.Sprintf("verifyBin: %s failed", binList),
+		fmt.Sprintf("failed to run: %s", cmd.Args),
 	)
 
 	// Actual verification
@@ -84,12 +90,18 @@ func verifyKubeVersion(b string) []string {
 	// TODO! Check the version number using kubectl, which is more likely to be on the path.
 	var w []string
 
+	_, err := exec.LookPath(b)
+	errmsgs += handleError(
+		err,
+		fmt.Sprintf("%s: command not found on path - version check skipped", b),
+	)
+
 	// Check version
 	cmd := exec.Command(b, "--version")
 	out, err := cmd.Output()
 	errmsgs += handleError(
 		err,
-		fmt.Sprintf("verifyKubeVersion: failed\nCommand:%s", cmd.Args),
+		fmt.Sprintf("failed to run:%s", cmd.Args),
 	)
 
 	matched := strings.Contains(string(out), kubeVersion)
-- 
GitLab