Fix absent namespaces for cluster-scoped resources in hierarchies #726
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #671, a case with cluster-scoped resources (which have no namespaces) was forgotten.
This PR fixes it: absent namespace in the owner object is not an error now,
None
is assigned as a namespace in children (as it was before the fix).Besides, a little optimization for clarity: the current contextual owner is looked up ONLY if
namespace=
is really unset, not when it is passed asNone
— for the case whenadjust_namespace(…, namespace=None)
is called fromadopt()
where the owner lookup is already performed.The same distinguishing logic of
None
-vs-unset is applied for "name" harmonization — also a string that can be sometimes absent in the owner — at least, in theory.The same for labels: passing
None
is a sign of an error (e.g., improper.get('labels')
?): labels cannot beNone
, but they can be{}
(as a default value inadopt()
).There are almost no changes in the tests because the contracts/signatures/behaviour do not change (except for namespaces of cluster-scoped resources), only the implementation is changed.
fixes #725