-
Notifications
You must be signed in to change notification settings - Fork 55
feat: allow resource.get to accept Namespace instance instead of just str #2391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: allow resource.get to accept Namespace instance instead of just str #2391
Conversation
This feature allows Namespace objects to be passed into the get function of NamespacedResources. Pod.get is an example which can directly accept a namespace avoiding confusion of where Namespace exists as a string.
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes introduce a custom string representation for the Changes
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
@@ -1368,7 +1368,7 @@ def _get() -> Generator["NamespacedResource|ResourceInstance", None, None]: | |||
yield cls( | |||
client=dyn_client, | |||
name=resource_field.metadata.name, | |||
namespace=resource_field.metadata.namespace, | |||
namespace=str(resource_field.metadata.namespace), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This issue seems like an user error situation. namespace here is namespace name. This is true for all wrapper objects, if I recall correctly. Just like an oc command does not work with kinds as params, wrapper expects namespace strings when you are providing a namespace.
Short description:
This feature allows Namespace objects to be passed into the get function of NamespacedResources. Pod.get is an example which can directly accept a namespace avoiding confusion of where Namespace exists as a string.
More details:
It's annoying to juggle between namespaces as strings and namespace objects. If the Namespace is passed into a function such as Pod.get it results in the field resolving to repr which is the default behavior.
What this PR does / why we need it:
I think this fixes two things but the implementation is mostly a suggestion.
Special notes for reviewer:
I'm quite new to the team so I hope you can give me more detailed guidance and steps to improve.
I really appreciate detailed, honest feedback!
Summary by CodeRabbit
New Features
Bug Fixes