You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Which project are you requesting an enhancement for?
kr8s
What do you need?
We use box to make accessing nested data structures more pleasant and pythonic.
Right now we just use the default box settings, which means any data structures that use camel case keys needs to be accessed via camel case attributes.
You can access the loadBalancer key using either .loadBalancer or .load_balancer. Which is very pleasant.
>>>data.load_balancerTrue>>>data.loadBalancerTrue
Unfortunately this operation in box is destructive and modifies the underlying data structure to store data in the snake case form. Which means when converting back to a dictionary you don't get the same structure that you put in.
>>>data.to_dict()
{'load_balancer': True}
Given that kr8s needs to be able to update data back to the Kubernetes API we can't be mangling the data structures like this.
It would be great if we could somehow support this snake case attribute access without modifying the data structure so that we can serialize data back out transparently.
The text was updated successfully, but these errors were encountered:
jacobtomlinson
changed the title
Camel killer box, support snake case attributes on data structures
Camel killer box, support snake case attributes on data structures non-destructively
Sep 17, 2024
Which project are you requesting an enhancement for?
kr8s
What do you need?
We use
box
to make accessing nested data structures more pleasant and pythonic.Right now we just use the default box settings, which means any data structures that use camel case keys needs to be accessed via camel case attributes.
Box supports a camel killer box to make keys like
loadBalancer
more pythonic by optionally converting them to snake case likeload_balancer
.You can access the
loadBalancer
key using either.loadBalancer
or.load_balancer
. Which is very pleasant.Unfortunately this operation in
box
is destructive and modifies the underlying data structure to store data in the snake case form. Which means when converting back to a dictionary you don't get the same structure that you put in.Given that
kr8s
needs to be able to update data back to the Kubernetes API we can't be mangling the data structures like this.It would be great if we could somehow support this snake case attribute access without modifying the data structure so that we can serialize data back out transparently.
The text was updated successfully, but these errors were encountered: