filter by namespace and nameprefix in namereference transformer

This commit is contained in:
Jingfang Liu
2018-09-05 13:10:33 -07:00
parent 4a297fa138
commit 7b301446fa
3 changed files with 52 additions and 2 deletions

View File

@@ -140,6 +140,18 @@ func (m ResMap) insert(newName string, obj *unstructured.Unstructured) error {
return nil
}
// FilterBy returns a ResMap containing ResIds with the same namespace and nameprefix
// with the inputId
func (m ResMap) FilterBy(inputId resource.ResId) ResMap {
result := ResMap{}
for id, res := range m {
if id.Namespace() == inputId.Namespace() && id.HasSamePrefix(inputId) {
result[id] = res
}
}
return result
}
// NewResourceSliceFromPatches returns a slice of resources given a patch path slice from a kustomization file.
func NewResourceSliceFromPatches(
loader loader.Loader, paths []patch.PatchStrategicMerge) ([]*resource.Resource, error) {