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.
This commit is contained in:
Jerome Brette
2019-06-25 17:04:55 -05:00
parent 74f5e74b89
commit 4272611593
2 changed files with 5 additions and 3 deletions

View File

@@ -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),

View File

@@ -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