Skip to content
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

Support converting objects to dicts #226

Merged
merged 1 commit into from
Dec 4, 2023

Conversation

jacobtomlinson
Copy link
Member

Libraries like kubernetes, kubernetes_asyncio and lightkube have a to_dict() method on their objects. We use this to convert to kr8s objects already. We should probably support this same API in case other libraries want to convert kr8s objects to dicts.

from kr8s.objects import Pod

pod = Pod(...)

spec = pod.to_dict()
# is equivalent to the kr8s specific `spec = pod.raw`

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (ef96441) 94.76% compared to head (7bf7973) 94.55%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #226      +/-   ##
==========================================
- Coverage   94.76%   94.55%   -0.22%     
==========================================
  Files          27       27              
  Lines        2638     2645       +7     
==========================================
+ Hits         2500     2501       +1     
- Misses        138      144       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jacobtomlinson jacobtomlinson merged commit 2922d31 into kr8s-org:main Dec 4, 2023
9 checks passed
@jacobtomlinson jacobtomlinson deleted the to_dict branch December 4, 2023 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant