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
Charles-Edouard Brétéché a4b889de63
feat: add ext/yaml package (#8760)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
2023-10-27 11:08:39 +00:00

16 lines
348 B
Go

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
}