1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2024-12-14 11:57:48 +00:00
kyverno/ext/yaml/empty.go

17 lines
348 B
Go
Raw Normal View History

package yaml
import (
"strings"
)
// IsEmptyDocument checks if a yaml document is empty (contains only comments)
func IsEmptyDocument(document document) bool {
for _, line := range strings.Split(string(document), "\n") {
line := strings.TrimSpace(line)
if line != "" && !strings.HasPrefix(line, "#") {
return false
}
}
return true
}