mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
cbeb5157d6
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
22 lines
384 B
Go
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
|
|
}
|