in pkg/safeguards/preprocessing/preprocessing.go [70:106]
func RenderKustomizeManifest(kustomizationPath string) ([]sgTypes.ManifestFile, error) {
log.Debugf("Rendering kustomization.yaml...")
if IsYAML(kustomizationPath) {
kustomizationPath = filepath.Dir(kustomizationPath)
}
options := &krusty.Options{
Reorder: "none",
LoadRestrictions: types.LoadRestrictionsRootOnly,
PluginConfig: &types.PluginConfig{},
}
k := krusty.MakeKustomizer(options)
// Run the build to generate the manifests
kustomizeFS := filesys.MakeFsOnDisk()
resMap, err := k.Run(kustomizeFS, kustomizationPath)
if err != nil {
return nil, fmt.Errorf("error building manifests: %s", err.Error())
}
// Output the manifests
var manifestFiles []sgTypes.ManifestFile
for _, res := range resMap.Resources() {
yamlRes, err := res.AsYAML()
if err != nil {
return nil, fmt.Errorf("error converting resource to YAML: %s", err.Error())
}
// write yamlRes to dir
manifestFiles = append(manifestFiles, sgTypes.ManifestFile{
Name: res.GetName(),
ManifestContent: yamlRes,
})
}
return manifestFiles, nil
}