Skip to content

Commit

Permalink
standardise subresource trait names
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Feb 7, 2021
1 parent d1b4925 commit 4015aa7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
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

0 comments on commit 4015aa7

Please sign in to comment.