Skip to content

implement the last subresources #127

@clux

Description

@clux

Subresources have a lot of special case logic, that is not easily derivable from k8s_openapi. So far we have implemented (see subresources.rs):

The general outline for the http based subresources:

We need a definition of what they are in subresources. The way to upgrade would be:

  1. Implement subresource queries straight on Resource without restrictions (for now):
impl Resource {
    /// Get a pod logs
    pub fn log(&self, name: &str, lp: &LogParams) -> Result<http::Request<Vec<u8>>> {
        ...
        // Check https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.17/ for urls
    }
}
  1. Make a marker trait for the subresource:
pub trait Loggable {}

impl<K> Api<K>
where
    K: Clone + DeserializeOwned + Meta + Loggable,
{
    pub async fn log(&self, name: &str, lp: &LogParams) -> Result<String> {
        let req = self.api.log(name, lp)?;
        Ok(self.client.request_text(req).await?)
    }

    pub async fn log_stream(&self, name: &str, lp: &LogParams) -> Result<impl Stream<Item = Result<Bytes>>> {
        let req = self.api.log(name, lp)?;
        Ok(self.client.request_text_stream(req).await?)
    }
}
  1. Designate what resources implement this subresource:
impl Loggable for k8s_openapi::api::core::v1::Pod {}

Write one test case for one resource in examples (e.g. examples/log_openapi.rs).

EDIT (0.46.0):

Now this is not as difficult for the specialized requests requiring websockets (ws feature).
This was discussed at length in #229, and finally implemented in #360.
Implementors of the last subresources ought to look at that PR for help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiApi abstraction relatedclient-goldgold client requirementshelp wantedNot immediately prioritised, please help!

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions