diff --git a/sys/sys.go b/sys/sys.go index d133295..30fdb64 100644 --- a/sys/sys.go +++ b/sys/sys.go @@ -2,6 +2,7 @@ package sys import ( "bytes" + "errors" "fmt" "io" "os" @@ -147,3 +148,11 @@ func IsRunningOnPod() bool { var bufout bytes.Buffer return PipeCmd(exec.Command("cat", "/proc/1/cgroup"), exec.Command("grep", "kubepods"), &bufout) == 0 } + +func IsFileExists(path string) bool { + exists := false + if _, err := os.Open(path); !errors.Is(err, os.ErrNotExist) { + exists = true + } + return exists +}