1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/cmd/cli/kubectl-kyverno/source/stdin.go
Charles-Edouard Brétéché cbeb5157d6
refactor: cli policy package (#8279)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-09-05 23:01:31 +00:00

22 lines
384 B
Go

package source
import (
"os"
)
var defaultStater = (*os.File).Stat
func IsStdin(path string) bool {
return path == "-" && isStdin(defaultStater)
}
func isStdin(stater func(*os.File) (os.FileInfo, error)) bool {
if stater == nil {
stater = defaultStater
}
fileInfo, err := stater(os.Stdin)
if err != nil {
return false
}
return fileInfo.Mode()&os.ModeCharDevice == 0
}