From 2f5fa95d14e5983e9b26aff331341c17a5b0d51c Mon Sep 17 00:00:00 2001 From: Gregory Kurtzer Date: Tue, 1 Dec 2020 23:34:05 -0800 Subject: [PATCH] Minor updates to add debugging to some utils --- internal/pkg/util/util.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/pkg/util/util.go b/internal/pkg/util/util.go index a25896c7..f1c537f5 100644 --- a/internal/pkg/util/util.go +++ b/internal/pkg/util/util.go @@ -11,7 +11,6 @@ import ( "path/filepath" "regexp" "time" - // "strings" ) @@ -90,8 +89,9 @@ func CopyFile(source string, dest string) error { //TODO: func CopyRecursive ... +func IsDir(path string) bool { + wwlog.Printf(wwlog.DEBUG, "Chcking if path exists as a directory: %s\n", path) -func IsDir(path string) (bool) { if path == "" { return false } @@ -101,7 +101,9 @@ func IsDir(path string) (bool) { return false } -func IsFile(path string) (bool) { +func IsFile(path string) bool { + wwlog.Printf(wwlog.DEBUG, "Chcking if path exists as a file: %s\n", path) + if path == "" { return false } @@ -112,7 +114,6 @@ func IsFile(path string) (bool) { return false } - func TaintCheck(pattern string, expr string) bool { if b, _ := regexp.MatchString(expr, pattern); b == true { return true @@ -148,7 +149,7 @@ func FindFiles(path string) []string { if IsDir(location) == true { wwlog.Printf(wwlog.DEBUG, "FindFiles() found directory: %s\n", location) - ret = append(ret, location +"/") + ret = append(ret, location+"/") } else { wwlog.Printf(wwlog.DEBUG, "FindFiles() found file: %s\n", location) ret = append(ret, location) @@ -163,7 +164,7 @@ func FindFiles(path string) []string { return ret } -func ExecInteractive(command string, a...string) error { +func ExecInteractive(command string, a ...string) error { wwlog.Printf(wwlog.DEBUG, "ExecInteractive(%s, %s)\n", command, a) c := exec.Command(command, a...) c.Stdin = os.Stdin @@ -173,8 +174,6 @@ func ExecInteractive(command string, a...string) error { return err } - - func ShaSumFile(file string) (string, error) { var ret string @@ -192,7 +191,6 @@ func ShaSumFile(file string) (string, error) { return fmt.Sprintf("%x", h.Sum(nil)), nil } - func SliceRemoveElement(array []string, remove string) []string { var ret []string @@ -225,4 +223,4 @@ func SliceAddUniqueElement(array []string, add string) []string { } return ret -} \ No newline at end of file +}