Skip to content

Commit bb9a44e

Browse files
authored
Upgrades Tower to 0.5.1 (#1589)
fixes #1569 Signed-off-by: Mark Ingram <mark@lincs.dev>
1 parent acd2d8e commit bb9a44e

6 files changed

Lines changed: 16 additions & 11 deletions

File tree

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ http = "1.1.0"
5252
http-body = "1.0.0"
5353
http-body-util = "0.1.2"
5454
hyper = "1.2.0"
55-
hyper-util = "0.1.3"
55+
hyper-util = "0.1.9"
5656
hyper-openssl = "0.10.2"
5757
hyper-rustls = { version = "0.27.1", default-features = false }
5858
hyper-socks2 = { version = "0.9.0", default-features = false }
@@ -84,8 +84,8 @@ tokio = "1.14.0"
8484
tokio-test = "0.4.0"
8585
tokio-tungstenite = "0.24.0"
8686
tokio-util = "0.7.0"
87-
tower = "0.4.13"
88-
tower-http = "0.5.2"
87+
tower = "0.5.1"
88+
tower-http = "0.6.1"
8989
tower-test = "0.4.0"
9090
tracing = "0.1.36"
9191
tracing-subscriber = "0.3.17"

examples/custom_client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use hyper_util::rt::TokioExecutor;
22
// Minimal custom client example.
33
use k8s_openapi::api::core::v1::Pod;
4+
use tower::BoxError;
45
use tracing::*;
56

67
use kube::{client::ConfigExt, Api, Client, Config, ResourceExt};
@@ -15,6 +16,7 @@ async fn main() -> anyhow::Result<()> {
1516
let service = tower::ServiceBuilder::new()
1617
.layer(config.base_uri_layer())
1718
.option_layer(config.auth_layer()?)
19+
.map_err(BoxError::from)
1820
.service(hyper_util::client::legacy::Client::builder(TokioExecutor::new()).build(https));
1921
let client = Client::new(service, config.default_namespace);
2022

examples/custom_client_trace.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use hyper::body::Incoming;
44
use hyper_util::rt::TokioExecutor;
55
use k8s_openapi::api::core::v1::Pod;
66
use std::time::Duration;
7-
use tower::ServiceBuilder;
7+
use tower::{BoxError, ServiceBuilder};
88
use tower_http::{decompression::DecompressionLayer, trace::TraceLayer};
99
use tracing::{Span, *};
1010

@@ -54,6 +54,7 @@ async fn main() -> anyhow::Result<()> {
5454
tracing::debug!("finished in {}ms", latency.as_millis())
5555
}),
5656
)
57+
.map_err(BoxError::from)
5758
.service(hyper_util::client::legacy::Client::builder(TokioExecutor::new()).build(https));
5859

5960
let client = Client::new(service, config.default_namespace);

kube-client/src/client/builder.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ where
213213
}
214214
}),
215215
)
216+
.map_err(BoxError::from)
216217
.service(client);
217218

218219
Ok(ClientBuilder::new(

kube-client/src/client/config_ext.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,14 @@ impl ConfigExt for Config {
167167
fn auth_layer(&self) -> Result<Option<AuthLayer>> {
168168
Ok(match Auth::try_from(&self.auth_info).map_err(Error::Auth)? {
169169
Auth::None => None,
170-
Auth::Basic(user, pass) => Some(AuthLayer(Either::A(
170+
Auth::Basic(user, pass) => Some(AuthLayer(Either::Left(
171171
AddAuthorizationLayer::basic(&user, pass.expose_secret()).as_sensitive(true),
172172
))),
173-
Auth::Bearer(token) => Some(AuthLayer(Either::A(
173+
Auth::Bearer(token) => Some(AuthLayer(Either::Left(
174174
AddAuthorizationLayer::bearer(token.expose_secret()).as_sensitive(true),
175175
))),
176176
Auth::RefreshableToken(refreshable) => {
177-
Some(AuthLayer(Either::B(AsyncFilterLayer::new(refreshable))))
177+
Some(AuthLayer(Either::Right(AsyncFilterLayer::new(refreshable))))
178178
}
179179
Auth::Certificate(_client_certificate_data, _client_key_data) => None,
180180
})

kube-client/src/client/mod.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! The [`Client`] can also be used with [`Discovery`](crate::Discovery) to dynamically
99
//! retrieve the resources served by the kubernetes API.
1010
use either::{Either, Left, Right};
11-
use futures::{AsyncBufRead, StreamExt, TryStream, TryStreamExt};
11+
use futures::{future::BoxFuture, AsyncBufRead, StreamExt, TryStream, TryStreamExt};
1212
use http::{self, Request, Response};
1313
use http_body_util::BodyExt;
1414
#[cfg(feature = "ws")] use hyper_util::rt::TokioIo;
@@ -75,8 +75,8 @@ pub use builder::{ClientBuilder, DynBody};
7575
#[derive(Clone)]
7676
pub struct Client {
7777
// - `Buffer` for cheap clone
78-
// - `BoxService` for dynamic response future type
79-
inner: Buffer<BoxService<Request<Body>, Response<Body>, BoxError>, Request<Body>>,
78+
// - `BoxFuture` for dynamic response future type
79+
inner: Buffer<Request<Body>, BoxFuture<'static, Result<Response<Body>, BoxError>>>,
8080
default_ns: String,
8181
}
8282

@@ -102,13 +102,14 @@ impl Client {
102102
/// ```rust
103103
/// # async fn doc() -> Result<(), Box<dyn std::error::Error>> {
104104
/// use kube::{client::ConfigExt, Client, Config};
105-
/// use tower::ServiceBuilder;
105+
/// use tower::{BoxError, ServiceBuilder};
106106
/// use hyper_util::rt::TokioExecutor;
107107
///
108108
/// let config = Config::infer().await?;
109109
/// let service = ServiceBuilder::new()
110110
/// .layer(config.base_uri_layer())
111111
/// .option_layer(config.auth_layer()?)
112+
/// .map_err(BoxError::from)
112113
/// .service(hyper_util::client::legacy::Client::builder(TokioExecutor::new()).build_http());
113114
/// let client = Client::new(service, config.default_namespace);
114115
/// # Ok(())

0 commit comments

Comments
 (0)