From 2f8a376ae4a93cb6de9a53e9051cabe3dce92f14 Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Thu, 17 Sep 2020 12:46:18 -0700 Subject: [PATCH] fix namespace will match all empty namespace --- api/resmap/reswrangler.go | 4 ++-- api/resmap/selector_test.go | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/resmap/reswrangler.go b/api/resmap/reswrangler.go index ed95572a9..618c64f8d 100644 --- a/api/resmap/reswrangler.go +++ b/api/resmap/reswrangler.go @@ -530,7 +530,7 @@ func (m *resWrangler) Select(s types.Selector) ([]*resource.Resource, error) { // matches the namespace when namespace is not empty in the selector // It first tries to match with the original namespace // then matches with the current namespace - if r.GetNamespace() != "" { + if s.Namespace != "" { matched := ns.MatchString(orgId.EffectiveNamespace()) if !matched { matched = ns.MatchString(curId.EffectiveNamespace()) @@ -543,7 +543,7 @@ func (m *resWrangler) Select(s types.Selector) ([]*resource.Resource, error) { // matches the name when name is not empty in the selector // It first tries to match with the original name // then matches with the current name - if r.GetName() != "" { + if s.Name != "" { matched := nm.MatchString(orgId.Name) if !matched { matched = nm.MatchString(curId.Name) diff --git a/api/resmap/selector_test.go b/api/resmap/selector_test.go index cd10d26b9..8fb79d865 100644 --- a/api/resmap/selector_test.go +++ b/api/resmap/selector_test.go @@ -164,6 +164,12 @@ func TestFindPatchTargets(t *testing.T) { }, count: 2, }, + { + target: types.Selector{ + Namespace: "foo", + }, + count: 0, + }, } for _, testcase := range testcases { actual, err := rm.Select(testcase.target)