Support for ConfigMap generator with identical names in different namespaces.

- Attempt to account, at build time, for subsequent kubectl apply behavior.
  (empty or no namespace means default).
- Account for the fact that not all objects have a namespace.
- Add new Equal method to ResId address merge name conflict
- Add GroupByName to resources by namespaces to resolve filenames conflict
- Added corresponding unit tests.
- Change the fail test for issue #1155
This commit is contained in:
Jerome Brette
2019-06-20 12:33:27 -05:00
parent 762d3143eb
commit 2bba0a6aa3
5 changed files with 216 additions and 20 deletions

View File

@@ -93,5 +93,25 @@ func (id ResId) GvknEquals(o ResId) bool {
// Equals returns true if the other id matches
// namespace/Group/Version/Kind/name.
func (id ResId) Equals(o ResId) bool {
return id.Namespace == o.Namespace && id.GvknEquals(o)
return id.IsNsEquals(o) && id.GvknEquals(o)
}
// IsNsEquals returns true if the other id matches namespace
// or both are in the default namespace
// or both are not namespaceable id.
func (id ResId) IsNsEquals(o ResId) bool {
return id.Namespace == o.Namespace ||
(id.IsInDefaultNs() && o.IsInDefaultNs()) ||
(!id.IsNamespaceable() && !o.IsNamespaceable())
}
// IsInDefaultNs returns true if id is a namespable ResId and the Namespace
// is either not set or set to "default"
func (id ResId) IsInDefaultNs() bool {
return id.IsNamespaceable() && (id.Namespace == "" || id.Namespace == "default")
}
// IsNamespaceable returns true if id is a namespable ResId
func (id ResId) IsNamespaceable() bool {
return id.IsNamespaceableKind()
}