-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add to_dict method to ResourceField #1886
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
Add to_dict method to ResourceField #1886
Conversation
Welcome @0xFelix! |
/assign @fabianvf |
@fabianvf Ping |
@pmareke Thanks! Can you describe this in a little more detail? I'm not sure how you would change it.
|
@0xFelix I mean just invert the order of the methods: Move the |
@pmareke Sorry, got it! |
Great job @0xFelix !! As you're using returns in each if you can simplify a little bit the method: def __serialize(self, field):
if isinstance(field, ResourceField):
return {
k: self.__serialize(v) for k, v in field.__dict__.items()
}
if isinstance(field, (list, tuple)):
return [self.__serialize(item) for item in field]
return field |
This allows to recursively convert ResourceFields to dicts. Signed-off-by: Felix Matouschek <[email protected]>
@pmareke Done! |
The Kubernetes project currently lacks enough contributors to adequately respond to all PRs. This bot triages PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 0xFelix, roycaihw The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This allows to recursively convert ResourceFields to dicts.
Does this PR introduce a user-facing change?