config tree defaults to graph structure when ownerRefs available

This commit is contained in:
Katrina Verey
2019-12-23 16:36:25 -05:00
parent 3900166fdf
commit 24cf0c1fdc
5 changed files with 231 additions and 18 deletions

View File

@@ -98,9 +98,15 @@ func (p TreeWriter) Write(nodes []*yaml.RNode) error {
return p.packageStructure(nodes)
case TreeStructureGraph:
return p.graphStructure(nodes)
default:
return p.packageStructure(nodes)
}
// If any resource has an owner reference, default to the graph structure. Otherwise, use package structure.
for _, node := range nodes {
if owners, _ := node.Pipe(yaml.Lookup("metadata", "ownerReferences")); owners != nil {
return p.graphStructure(nodes)
}
}
return p.packageStructure(nodes)
}
// node wraps a tree node, and any children nodes