[rustyk8s] Elephant in the room?

Robert Collins robertc at robertcollins.net
Tue Feb 12 22:17:26 UTC 2019


Thats a pretty nice crate and I applaud its design decisions vis-a-vis
network / IO abstractions, and the nice Options structs.

However its a huge amount of code duplication - the k8s-openapi crate
is 3.5M! - consider
https://github.com/Arnavion/k8s-openapi-codegen/blob/master/k8s-openapi/src/v1_13/mod.rs
- every response function is basically the same - ```
fn try_from_parts(status_code: http::StatusCode, buf: &[u8]) ->
Result<(Self, usize), crate::ResponseError> {
    match status_code {
        http::StatusCode::OK => {
            let result = match serde_json::from_slice(buf) {
                Ok(value) => value,
                Err(ref err) if err.is_eof() => return
Err(crate::ResponseError::NeedMoreData),
                Err(err) => return Err(crate::ResponseError::Json(err)),
            };
        Ok((GetAdmissionregistrationAPIGroupResponse::Ok(result), buf.len()))
        },
        http::StatusCode::UNAUTHORIZED =>
Ok((GetAdmissionregistrationAPIGroupResponse::Unauthorized, 0)),
        _ => Ok((GetAdmissionregistrationAPIGroupResponse::Other, 0)),
    }
}
```

What gus and I are aiming at is having this itself parameterised by an
API type, permitting a single implementation to serve for both core
types and CRDs.

-Rob


On Sun, 10 Feb 2019 at 14:01, Peter Salvatore <peter at psftw.com> wrote:
>
> Recently I spent an evening looking around at the existing rust crates related to k8s and one of them really stood out to me: https://github.com/Arnavion/k8s-openapi-codegen  At first glance this looks like an incredible library to depend on for building K8S-related things that need to function against multiple versions of the API.  The README describing some of the design decisions is also entertaining: https://github.com/Arnavion/k8s-openapi-codegen/tree/master/k8s-openapi
>
> Call me impressed! If I wind up building anything, it will likely be based on the above project. :-)  Thank you Arnav!
>
> -Peter
> _______________________________________________
> rustyk8s mailing list
> rustyk8s at lists.opendev.org
> http://lists.opendev.org/cgi-bin/mailman/listinfo/rustyk8s



More information about the rustyk8s mailing list