Define and implement equivalent `k8s-openapi` traits
clux opened this issue · comments
A thing that can be done in parallel to the implementation of the code-generation, is to sketch out the traits we need to implement in the codegen, and whether we need to rethink them a bit.
There is currently a bit of a disparity between k8s-openapi
traits and kube_core
's traits, and it would be nice if the traits we used in kube
, were the traits defined either by kube_core
or something here.
So here's a rough list of generics I think we should aim to implement / refine for this project to be successful:
wanted traits
Need at least these two to be able to implement kube::Resource
upstream:
-
k8s-openapi::ResourceScope
equivalent. from old issue kube-rs/kube#194 - done in #25 -
k8s-openapi::Resource
equivalent - #14 + #25
getter traits
-
HasSpec
andHasStatus
: https://github.com/kube-rs/kube-rs/blob/master/kube-core/src/object.rs - #14 -
HasConditions
: needed for things like kube-rs/kube#679 - #14 -
HasMetadata
:: an analogue of thek8s_openapi::Metadata
trait - #14
There are probably room for more things, but we should decide where generics should live.
Here? Or separate repo? I'm leaning towards defining a kube-traits
crate within the kube-rs
org and implementing it here.
But open to ideas. Also, anything missing from this list?
Descoped
These could maybe be done later for even more generic action.
- verb traits for subresources (e.g.
Log
- these should probably not live inkube-client
) - verb traits for normal resources - enables neokubism kube-rs/kube#594
I'm not sure where everything should be yet, but I'll transfer this repo to the org. Protobuf + Generics derived from OpenAPI looks promising to me, and even if we decide to create a new repo after experimenting more in this one, we can always rename this to k8s-pb-archived
or something.
Updated to reflect progress.
Have added Scope
and aligned the in-house Resource
trait with the one in k8s-openapi
now. This means it is theoretically possible to impl<K: k8s_pb::Resource> kube::Resource
for K` in the same way as kube_core does it.
There are potentially more improvements here, but starting out with the full verb soup generics is probably overkill. Closing this as sufficient to get going for now, but open to improvements in the future.