Add an option to fill default namespace in manifest if no other namespace set#9
Add an option to fill default namespace in manifest if no other namespace set#9alexsomesan wants to merge 1 commit into
Conversation
| stripServerSideFields(formattable) | ||
| } | ||
|
|
||
| if defaultNamespace { |
There was a problem hiding this comment.
I think instead of doing this mutation here, we can just add this conditional to stripServerSideFields and just not delete the namespace key. I think doing it this way will add a namespace to resources that are not namespaced?
There was a problem hiding this comment.
That was my first intent as well, but then I realized that stripServerSideFields is only being called when -s is passed on the CLI.
The two operations felt kind of orthogonal so I went like this. Do you mean I should drop the -n flag and just do this as part of stripServerSideFields?
There was a problem hiding this comment.
Well -n will only do something if -s is set anyway, because the default namespace always gets sent back and won't get stripped.
I think maybe we can just remove the delete namespace line from stripServerSideFields
This change introduces a falg to enable filling the default namespace in the manifest when no namespace is specified. By default the flag is off and the tool behaves just like before this change.
The solution is not ideal because there doesn't seem to be a robust way to check if a specific resource type requires a namespace without actually making API calls to a cluster. However, there seem to be on average more resources requiring a namespace then not in a specific setup, so it's easier to add namespace everywhere and then remove it from the resources that don't need it.
Of course, if it turns out there is a way to formally identify namespaced resources offline, this feature should make use of that.