mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-30 09:51:23 +00:00
skip filtering resmap when the resource is a cluster level resource
This commit is contained in:
@@ -123,7 +123,11 @@ func (m ResMap) DeepCopy(rf *resource.Factory) ResMap {
|
||||
|
||||
// FilterBy returns a ResMap containing ResIds with the same namespace and nameprefix
|
||||
// with the inputId
|
||||
// If inputId is a cluster level resource, return the original resmap
|
||||
func (m ResMap) FilterBy(inputId resid.ResId) ResMap {
|
||||
if inputId.Gvk().IsClusterKind() {
|
||||
return m
|
||||
}
|
||||
result := ResMap{}
|
||||
for id, res := range m {
|
||||
if id.Namespace() == inputId.Namespace() && id.HasSameLeftmostPrefix(inputId) {
|
||||
|
||||
@@ -160,6 +160,11 @@ func TestFilterBy(t *testing.T) {
|
||||
if !reflect.DeepEqual(rm, ns1map) {
|
||||
t.Fatalf("Expected %v but got back %v", rm, ns1map)
|
||||
}
|
||||
|
||||
clmap := rm1.FilterBy(resid.NewResId(gvk.Gvk{Kind: "ClusterRoleBinding"}, "crb"))
|
||||
if !reflect.DeepEqual(rm1, clmap) {
|
||||
t.Fatalf("Expected %v but got back %v", rm1, clmap)
|
||||
}
|
||||
}
|
||||
func TestDeepCopy(t *testing.T) {
|
||||
rm1 := ResMap{
|
||||
|
||||
Reference in New Issue
Block a user