Skip to content

Commit

Permalink
Add feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
co42 committed Apr 27, 2023
1 parent 55a0e2d commit d4a43b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion kube-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ rust-version = "1.63.0"
edition = "2021"

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

[package.metadata.docs.rs]
features = ["k8s-openapi/v1_26", "unstable-runtime"]
Expand Down
10 changes: 6 additions & 4 deletions kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1016,16 +1016,17 @@ where
/// For example, this can be used to watch resources once and use the stream to trigger reconciliation and also keep a cache of those objects.
/// That way it's possible to use this up to date cache instead of querying Kubernetes to access those resources
///
/// Example:
/// # Example:
///
/// ```no_run
/// # async {
/// # use futures::{StreamExt, TryStreamExt};
/// # use k8s_openapi::api::core::v1::{ConfigMap, Pod};
/// # use kube::api::{Api, ListParams};
/// # use kube::api::Api;
/// # use kube::runtime::controller::Action;
/// # use kube::runtime::reflector::{ObjectRef, Store};
/// # use kube::runtime::{reflector, watcher, Controller, WatchStreamExt};
/// # use kube::runtime::watcher::Config;
/// # use kube::{Client, Error, ResourceExt};
/// # use std::future;
/// # use std::sync::Arc;
Expand All @@ -1038,20 +1039,21 @@ where
/// let (pod_store, writer) = reflector::store();
/// let pod_stream = reflector(
/// writer,
/// watcher(Api::<Pod>::all(client.clone()), ListParams::default()),
/// watcher(Api::<Pod>::all(client.clone()), Config::default()),
/// )
/// .applied_objects()
/// // Map to the relevant `ObjectRef<K>` to reconcile
/// .map_ok(|pod| ObjectRef::new(&format!("{}-cm", pod.name_any())).within(&pod.namespace().unwrap()));
///
/// Controller::new(Api::<ConfigMap>::all(client), ListParams::default())
/// Controller::new(Api::<ConfigMap>::all(client), Config::default())
/// .reconcile_on(pod_stream)
/// // The store can be re-used between controllers and even inspected from the reconciler through [Context]
/// .run(reconcile, error_policy, Arc::new(pod_store))
/// .for_each(|_| future::ready(()))
/// .await;
/// # };
/// ```
#[cfg(feature = "unstable-runtime-reconcile-on")]
#[must_use]
pub fn reconcile_on(
mut self,
Expand Down

0 comments on commit d4a43b3

Please sign in to comment.