kube-rs / k8s-pb

Playing with Kubernetes protobufs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

getter traits

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 in kube-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.