From 390764388039a2692e7df3652e2a60de9f443a2b Mon Sep 17 00:00:00 2001 From: Donny Xia Date: Wed, 22 Jul 2020 10:17:56 -0700 Subject: [PATCH] Add function to check role binding namespace --- api/resmap/resmap.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/api/resmap/resmap.go b/api/resmap/resmap.go index 9ae9f0af1..b86b2f699 100644 --- a/api/resmap/resmap.go +++ b/api/resmap/resmap.go @@ -618,13 +618,19 @@ func (m *resWrangler) SubsetThatCouldBeReferencedByResource( // the outer most suffix and the last prefix. Use PrefixedSuffixesEquals instead. resId := r.CurId() if (!isInputIdNamespaceable || !resId.IsNamespaceableKind() || resId.IsNsEquals(inputId) || - subjectNamespaces[r.GetNamespace()]) && r.InSameKustomizeCtx(rctxm) { + isRoleBindingNamespace(&subjectNamespaces, r.GetNamespace())) && r.InSameKustomizeCtx(rctxm) { result.append(r) } } return result } +// isRoleBindingNamespace returns true is the namespace `ns` is in role binding +// namespaces `m` +func isRoleBindingNamespace(m *map[string]bool, ns string) bool { + return (*m)[ns] +} + // getNamespacesForRoleBinding returns referenced ServiceAccount namespaces if the inputRes is // a RoleBinding func getNamespacesForRoleBinding(inputRes *resource.Resource) map[string]bool {