in pkg/gcv/configs/config.go [116:138]
func LoadUnstructuredFromContents(files []*PolicyFile) ([]*unstructured.Unstructured, error) {
var yamlDocs []*unstructured.Unstructured
for _, file := range files {
documents := strings.Split(string(file.Content), "\n---")
for _, rawDoc := range documents {
document := strings.TrimLeft(rawDoc, "\n ")
if len(document) == 0 {
continue
}
var u unstructured.Unstructured
_, _, err := scheme.Codecs.UniversalDeserializer().Decode([]byte(document), nil, &u)
if err != nil {
return nil, errors.Wrapf(err, "failed to decode %s", file.Path)
}
setAnnotation(&u, yamlPath, file.Path)
yamlDocs = append(yamlDocs, &u)
}
}
return yamlDocs, nil
}