-
-
Notifications
You must be signed in to change notification settings - Fork 324
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
Allow handling special verbs/resources #30
Comments
We can make a We do have do do some basic native object mapping of types to enum names anyway, so may as well map generic actions to those types. At least, this is the cleanest way of doing it, I've thought of so far. Happy to take PRs for it. Don't have an immediate need for it myself yet. |
We have a decent pattern for this that doesn't require massive amounts of generics:
impl RawApi {
/// Get a pod logs
pub fn log(&self, name: &str, lp: &LogParams) -> Result<http::Request<Vec<u8>>> {
...
}
}
pub trait LoggingObject {}
impl<K> Api<K>
where
K: Clone + DeserializeOwned + KubeObject + LoggingObject,
{
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?)
}
}
impl LoggingObject for Object<PodSpec, PodStatus> {}
impl LoggingObject for Object<PodSpec, Void> {} That ought to be it. Write one test case in examples (e.g. examples/log_openapi.rs). Ought to be simple PRs for people who need extra functionality for subresources! |
Opened #127 to replace this. |
There's a couple of special resources that need to be handled in less generic ways. E.g. just on pods alone:
pods/attach
pods/portforward
pods/eviction
pods/exec
pods/log
and maybe some node specific stuff. Don't see
drain
+cordon
in the openapi.We could allow customising these, but maybe the list is short enough to just have it as a feature.
The text was updated successfully, but these errors were encountered: