kube icon indicating copy to clipboard operation
kube copied to clipboard

Utilize HasSpec and HasObject traits for api methods

Open clux opened this issue 5 years ago • 3 comments

From a scan of k8s-openapi it does appear that it's only the Object<P, U> types, i.e. objects that look like:

  • typemeta (kind + apiVersion)
  • metadata
  • spec
  • status

That actually support the status subresource methods.

If we had a trait for "implements the spec and status model", then we might be able to implement it more accurately in subresource.rs and actually constrain the type definition for what goes in and comes out of the api methods there.

    pub async fn replace_status(&self, name: &str, pp: &PostParams, data: Vec<u8>) -> Result<K> {
        let req = self.resource.replace_status(name, &pp, data)?;
        self.client.request::<K>(req).await
    }

currently they are awkwardly all handling bytes as input. ..but then again, people will want to use server side apply on pretty much everything here anyway, so maybe it's not worth it.

clux avatar Jul 26 '20 17:07 clux

A trait similar to this this would also be useful for the scale subresource, allowing us to could help close #142. Though I suspect either of these would have to be defined on the k8s-openapi side (and implemented there for structs that allow it).

clux avatar Jul 26 '20 18:07 clux

Another annoying point; subresources may need two versions by the look of the APIResource struct

clux avatar Jul 27 '20 11:07 clux

We have had traits for this for a while; HasSpec and HasStatus (convenience for Object), but we are actually filling these out in k8s-pb: https://github.com/kube-rs/k8s-pb/issues/4 so this can be solved after the protobuf issue #371

clux avatar Nov 03 '21 23:11 clux