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

Genericize PartialObjectMeta over the underlying Resource #1152

Merged
merged 9 commits into from
Mar 2, 2023
Prev Previous commit
Next Next commit
simplify trait bound to just the empty dyn type
avoids unstable associated trait bounds + lints showing that the default really had to be the empty type.

Signed-off-by: clux <[email protected]>
  • Loading branch information
clux committed Mar 1, 2023
commit c228fb6261b6dc5b613b76d8e092263d30eb025c
12 changes: 4 additions & 8 deletions kube-core/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,15 @@ pub trait PartialObjectMetaExt: private::Sealed {
/// because it contains erased `TypeMeta` (and the apiserver is doing the erasing).
///
/// This method is useful when unit testing local behaviour.
fn into_response_partial<K: Resource>(self) -> PartialObjectMeta<K>;
fn into_response_partial<K>(self) -> PartialObjectMeta<K>;
}

impl PartialObjectMetaExt for ObjectMeta {
fn into_request_partial<K: Resource<DynamicType = ()>>(self) -> PartialObjectMeta<K>
where
K::DynamicType: Default,
{
let dyntype: K::DynamicType = Default::default();
fn into_request_partial<K: Resource<DynamicType = ()>>(self) -> PartialObjectMeta<K> {
PartialObjectMeta {
types: Some(TypeMeta {
api_version: K::api_version(&dyntype).into(),
kind: K::kind(&dyntype).into(),
api_version: K::api_version(&()).into(),
kind: K::kind(&()).into(),
}),
metadata: self,
_phantom: PhantomData,
Expand Down