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

standardise subresource trait names #395

Merged
merged 1 commit into from
Feb 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
UNRELEASED
===================
* see https://github.com/clux/kube-rs/compare/0.48.0...master
* `kube` subresource support added for `Evictable` types (marked for `Pod`) - #393
* `kube` subresource marker traits renamed to `Loggable`, `Executable`, `Attachable` (previously `LoggingObject`, `ExecutingObject`, `AttachableObject`) - #395

0.48.0 / 2021-01-23
===================
Expand Down
4 changes: 2 additions & 2 deletions kube/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub use dynamic::DynamicResource;

mod subresource;
#[cfg(feature = "ws")]
pub use subresource::{AttachParams, AttachableObject, ExecutingObject};
pub use subresource::{EvictParams, Evictable, LogParams, LoggingObject, ScaleSpec, ScaleStatus};
pub use subresource::{AttachParams, Attachable, Executable};
pub use subresource::{EvictParams, Evictable, LogParams, Loggable, ScaleSpec, ScaleStatus};

pub(crate) mod object;
pub use self::object::{Object, ObjectList, WatchEvent};
Expand Down
18 changes: 9 additions & 9 deletions kube/src/api/subresource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ fn log_path() {
}

/// Marker trait for objects that has logs
pub trait LoggingObject {}
pub trait Loggable {}

impl LoggingObject for k8s_openapi::api::core::v1::Pod {}
impl Loggable for k8s_openapi::api::core::v1::Pod {}

impl<K> Api<K>
where
K: Clone + DeserializeOwned + LoggingObject,
K: Clone + DeserializeOwned + Loggable,
{
/// Fetch logs as a string
pub async fn logs(&self, name: &str, lp: &LogParams) -> Result<String> {
Expand Down Expand Up @@ -481,17 +481,17 @@ fn attach_path() {
/// Marker trait for objects that has attach
#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
pub trait AttachableObject {}
pub trait Attachable {}

#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
impl AttachableObject for k8s_openapi::api::core::v1::Pod {}
impl Attachable for k8s_openapi::api::core::v1::Pod {}

#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
impl<K> Api<K>
where
K: Clone + DeserializeOwned + AttachableObject,
K: Clone + DeserializeOwned + Attachable,
{
/// Attach to pod
pub async fn attach(&self, name: &str, ap: &AttachParams) -> Result<AttachedProcess> {
Expand Down Expand Up @@ -546,17 +546,17 @@ fn exec_path() {
/// Marker trait for objects that has exec
#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
pub trait ExecutingObject {}
pub trait Executable {}

#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
impl ExecutingObject for k8s_openapi::api::core::v1::Pod {}
impl Executable for k8s_openapi::api::core::v1::Pod {}

#[cfg(feature = "ws")]
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
impl<K> Api<K>
where
K: Clone + DeserializeOwned + ExecutingObject,
K: Clone + DeserializeOwned + Executable,
{
/// Execute a command in a pod
pub async fn exec<I, T>(&self, name: &str, command: I, ap: &AttachParams) -> Result<AttachedProcess>
Expand Down