Skip to content

Commit

Permalink
Stabilise runtime predicates (#1578)
Browse files Browse the repository at this point in the history
* Stabilise runtime predicates

These are unlikely to undergo much changes (and if they do they are completely separated).
This should be an easy feature cleanup in runtime,
and one less need for unstable-runtime for common setups (i use this all the time).

Signed-off-by: clux <[email protected]>

* clippy

Signed-off-by: clux <[email protected]>

* remove stray reference to unstable in docs for the entrypoint

Signed-off-by: clux <[email protected]>

---------

Signed-off-by: clux <[email protected]>
Signed-off-by: Eirik A <[email protected]>
  • Loading branch information
clux authored Oct 9, 2024
1 parent 6688421 commit 62f95cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
3 changes: 1 addition & 2 deletions kube-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ keywords = ["kubernetes", "runtime", "reflector", "watcher", "controller"]
categories = ["web-programming::http-client", "caching", "network-programming"]

[features]
unstable-runtime = ["unstable-runtime-subscribe", "unstable-runtime-predicates", "unstable-runtime-stream-control", "unstable-runtime-reconcile-on"]
unstable-runtime = ["unstable-runtime-subscribe", "unstable-runtime-stream-control", "unstable-runtime-reconcile-on"]
unstable-runtime-subscribe = []
unstable-runtime-predicates = []
unstable-runtime-stream-control = []
unstable-runtime-reconcile-on = []

Expand Down
1 change: 0 additions & 1 deletion kube-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ pub use scheduler::scheduler;
pub use utils::WatchStreamExt;
pub use watcher::{metadata_watcher, watcher};

#[cfg(feature = "unstable-runtime-predicates")]
pub use utils::{predicates, Predicate};
pub use wait::conditions;
3 changes: 1 addition & 2 deletions kube-runtime/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ mod backoff_reset_timer;
pub(crate) mod delayed_init;
mod event_decode;
mod event_modify;
#[cfg(feature = "unstable-runtime-predicates")] mod predicate;
mod predicate;
mod reflect;
mod stream_backoff;
mod watch_ext;

pub use backoff_reset_timer::ResetTimerBackoff;
pub use event_decode::EventDecode;
pub use event_modify::EventModify;
#[cfg(feature = "unstable-runtime-predicates")]
pub use predicate::{predicates, Predicate, PredicateFilter};
pub use reflect::Reflect;
pub use stream_backoff::StreamBackoff;
Expand Down
13 changes: 6 additions & 7 deletions kube-runtime/src/utils/watch_ext.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#[cfg(feature = "unstable-runtime-predicates")]
use crate::utils::predicate::{Predicate, PredicateFilter};
use crate::{
utils::{event_decode::EventDecode, event_modify::EventModify, stream_backoff::StreamBackoff},
utils::{
event_decode::EventDecode,
event_modify::EventModify,
predicate::{Predicate, PredicateFilter},
stream_backoff::StreamBackoff,
},
watcher,
};
use kube_client::Resource;
Expand Down Expand Up @@ -94,8 +97,6 @@ pub trait WatchStreamExt: Stream {
/// Common use case for this is to avoid repeat events for status updates
/// by filtering on [`predicates::generation`](crate::predicates::generation).
///
/// **NB**: This is constructor requires an [`unstable`](https://github.com/kube-rs/kube/blob/main/kube-runtime/Cargo.toml#L17-L21) feature.
///
/// ## Usage
/// ```no_run
/// # use std::pin::pin;
Expand All @@ -116,7 +117,6 @@ pub trait WatchStreamExt: Stream {
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "unstable-runtime-predicates")]
fn predicate_filter<K, P>(self, predicate: P) -> PredicateFilter<Self, K, P>
where
Self: Stream<Item = Result<K, watcher::Error>> + Sized,
Expand Down Expand Up @@ -272,7 +272,6 @@ pub trait WatchStreamExt: Stream {
impl<St: ?Sized> WatchStreamExt for St where St: Stream {}

// Compile tests
#[cfg(feature = "unstable-runtime-predicates")]
#[cfg(test)]
pub(crate) mod tests {
use super::watcher;
Expand Down

0 comments on commit 62f95cd

Please sign in to comment.