sys - add IsFileExists
This commit is contained in:
parent
ef88ea018c
commit
eb55a2b266
|
@ -2,6 +2,7 @@ package sys
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
|
@ -147,3 +148,11 @@ func IsRunningOnPod() bool {
|
||||||
var bufout bytes.Buffer
|
var bufout bytes.Buffer
|
||||||
return PipeCmd(exec.Command("cat", "/proc/1/cgroup"), exec.Command("grep", "kubepods"), &bufout) == 0
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user