mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
17 lines
348 B
Go
17 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
|
||
|
}
|