From 427261159347198a9f35b2e274f5028718a9a41a Mon Sep 17 00:00:00 2001 From: Jerome Brette Date: Tue, 25 Jun 2019 17:04:55 -0500 Subject: [PATCH] Change key used sort "not namespaceable objects. - Use "%no_namespace% instead of "cluster-wide" - Ensure will be no conflict with a kubernetes valid namespace name. --- pkg/commands/build/build.go | 5 +++-- pkg/resmap/resmap.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkg/commands/build/build.go b/pkg/commands/build/build.go index 76e549d27..ec7977f3b 100644 --- a/pkg/commands/build/build.go +++ b/pkg/commands/build/build.go @@ -215,8 +215,9 @@ func writeIndividualFiles( // Preserve backward compatibility with kustomize 2.1.0. // No need to cluter filename with namespace if all the objects - // are in the same namespace. - if (nsNeeded) && (namespace != "cluster-wide") { + // are in the same namespace. The not namespaceable objects + // are grouped in the "%no_namespace%" bucket. + if (nsNeeded) && (namespace != "%no_namespace%") { basename = fmt.Sprintf( "%s_%s", strings.ToLower(namespace), diff --git a/pkg/resmap/resmap.go b/pkg/resmap/resmap.go index eddd4247a..d6b9a9acc 100644 --- a/pkg/resmap/resmap.go +++ b/pkg/resmap/resmap.go @@ -354,7 +354,8 @@ func (m *resWrangler) GetById(id resid.ResId) (*resource.Resource, error) { func (m *resWrangler) GroupedByNamespace() map[string][]*resource.Resource { byNamespace := make(map[string][]*resource.Resource) for _, res := range m.rList { - namespace := "cluster-wide" + // Add to the notNamespaceable bucket by default. + namespace := "%no_namespace%" if res.OrgId().IsNamespaceable() { namespace = res.OrgId().Namespace