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

chore: update kube dependencies to 0.83 #163

Merged
merged 1 commit into from
Jul 24, 2023
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
4 changes: 2 additions & 2 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ default-features = false
features = ["derive", "help", "env", "std"]

[dev-dependencies.k8s-openapi]
version = "0.17"
version = "0.18"
default-features = false
features = ["v1_26"]

[dev-dependencies.kube]
version = "0.80"
version = "0.83"
default-features = false
features = ["client", "derive", "openssl-tls", "runtime"]

Expand Down
11 changes: 7 additions & 4 deletions examples/watch_pods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ use anyhow::{bail, Result};
use clap::Parser;
use futures::prelude::*;
use k8s_openapi::api::core::v1::Pod;
use kube::{api::ListParams, runtime::watcher::Event, ResourceExt};
use kube::{
runtime::watcher::{self, Event},
ResourceExt,
};
use tokio::time;
use tracing::Instrument;

Expand Down Expand Up @@ -75,10 +78,10 @@ async fn main() -> Result<()> {
// This stream completes when shutdown is signaled; and the admin endpoint does not return ready
// until the first update is received.
tracing::debug!(?selector);
let params = selector
let watcher_config = selector
.iter()
.fold(ListParams::default(), |p, l| p.labels(l));
let pods = runtime.watch_all::<Pod>(params);
.fold(watcher::Config::default(), |p, l| p.labels(l));
let pods = runtime.watch_all::<Pod>(watcher_config);
let mut deadline = Some(deadline);
let task = tokio::spawn(
async move {
Expand Down
12 changes: 6 additions & 6 deletions kubert/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,23 @@ features = ["derive", "std"]
# Not used directly, but required to ensure that the k8s-openapi dependency is considered part of
# the "deps" graph rather than just the "dev-deps" graph
[dependencies.k8s-openapi]
version = "0.17"
version = "0.18"
optional = true
default-features = false

[dependencies.kube-client]
version = "0.80"
version = "0.83"
optional = true
default-features = false
features = ["client", "config"]

[dependencies.kube-core]
version = "0.80"
version = "0.83"
optional = true
default-features = false

[dependencies.kube-runtime]
version = "0.80"
version = "0.83"
optional = true
default-features = false

Expand All @@ -163,13 +163,13 @@ features = ["env-filter", "fmt", "json", "smallvec", "tracing-log"]
# === Dev ===

[dev-dependencies]
kube = { version = "0.80", default-features = false, features = ["runtime"] }
kube = { version = "0.83", default-features = false, features = ["runtime"] }
tokio-stream = "0.1"
tokio-test = "0.4"
tracing-subscriber = { version = "0.3", features = ["ansi"] }

[dev-dependencies.k8s-openapi]
version = "0.17"
version = "0.18"
default-features = false
features = ["v1_26"]

Expand Down
29 changes: 16 additions & 13 deletions kubert/src/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
shutdown, LogFilter, LogFormat, LogInitError,
};
use futures_core::Stream;
use kube_core::{params::ListParams, NamespaceResourceScope, Resource};
use kube_core::{NamespaceResourceScope, Resource};
use kube_runtime::{reflector, watcher};
use serde::de::DeserializeOwned;
use std::{fmt::Debug, hash::Hash, time::Duration};
Expand Down Expand Up @@ -290,13 +290,13 @@ impl<S> Runtime<S> {
pub fn watch<T>(
&mut self,
api: Api<T>,
params: ListParams,
watcher_config: watcher::Config,
) -> impl Stream<Item = watcher::Event<T>>
where
T: Resource + DeserializeOwned + Clone + Debug + Send + 'static,
T::DynamicType: Default,
{
let watch = watcher::watcher(api, params);
let watch = watcher::watcher(api, watcher_config);
let successful = errors::LogAndSleep::fixed_delay(self.error_delay, watch);
let initialized = self.initialized.add_handle().release_on_ready(successful);
shutdown::CancelOnShutdown::new(self.shutdown_rx.clone(), initialized)
Expand All @@ -306,12 +306,15 @@ impl<S> Runtime<S> {
///
/// See [`Runtime::watch`] for more details.
#[inline]
pub fn watch_all<T>(&mut self, params: ListParams) -> impl Stream<Item = watcher::Event<T>>
pub fn watch_all<T>(
&mut self,
watcher_config: watcher::Config,
) -> impl Stream<Item = watcher::Event<T>>
where
T: Resource + DeserializeOwned + Clone + Debug + Send + 'static,
T::DynamicType: Default,
{
self.watch(Api::all(self.client()), params)
self.watch(Api::all(self.client()), watcher_config)
}

/// Creates a namespace-level watch on the default Kubernetes client
Expand All @@ -321,15 +324,15 @@ impl<S> Runtime<S> {
pub fn watch_namespaced<T>(
&mut self,
ns: impl AsRef<str>,
params: ListParams,
watcher_config: watcher::Config,
) -> impl Stream<Item = watcher::Event<T>>
where
T: Resource<Scope = NamespaceResourceScope>,
T: DeserializeOwned + Clone + Debug + Send + 'static,
T::DynamicType: Default,
{
let api = Api::namespaced(self.client(), ns.as_ref());
self.watch(api, params)
self.watch(api, watcher_config)
}

/// Creates a cached watch with the given [`Api`]
Expand All @@ -344,7 +347,7 @@ impl<S> Runtime<S> {
pub fn cache<T>(
&mut self,
api: Api<T>,
params: ListParams,
watcher_config: watcher::Config,
) -> (Store<T>, impl Stream<Item = watcher::Event<T>>)
where
T: Resource + DeserializeOwned + Clone + Debug + Send + 'static,
Expand All @@ -353,7 +356,7 @@ impl<S> Runtime<S> {
let writer = reflector::store::Writer::<T>::default();
let store = writer.as_reader();

let watch = watcher::watcher(api, params);
let watch = watcher::watcher(api, watcher_config);
let cached = reflector::reflector(writer, watch);
let successful = errors::LogAndSleep::fixed_delay(self.error_delay, cached);
let initialized = self.initialized.add_handle().release_on_ready(successful);
Expand All @@ -368,13 +371,13 @@ impl<S> Runtime<S> {
#[inline]
pub fn cache_all<T>(
&mut self,
params: ListParams,
watcher_config: watcher::Config,
) -> (Store<T>, impl Stream<Item = watcher::Event<T>>)
where
T: Resource + DeserializeOwned + Clone + Debug + Send + 'static,
T::DynamicType: Clone + Default + Eq + Hash + Clone,
{
self.cache(Api::all(self.client()), params)
self.cache(Api::all(self.client()), watcher_config)
}

/// Creates a cached namespace-level watch on the default Kubernetes client
Expand All @@ -384,15 +387,15 @@ impl<S> Runtime<S> {
pub fn cache_namespaced<T>(
&mut self,
ns: impl AsRef<str>,
params: ListParams,
watcher_config: watcher::Config,
) -> (Store<T>, impl Stream<Item = watcher::Event<T>>)
where
T: Resource<Scope = NamespaceResourceScope>,
T: DeserializeOwned + Clone + Debug + Send + 'static,
T::DynamicType: Clone + Default + Eq + Hash + Clone,
{
let api = Api::namespaced(self.client(), ns.as_ref());
self.cache(api, params)
self.cache(api, watcher_config)
}
}

Expand Down