From 1c4294fa72a2f73be002ece078a8c56fef8dd6bd Mon Sep 17 00:00:00 2001 From: Eirik A Date: Wed, 1 Nov 2023 14:52:41 +0000 Subject: [PATCH] Fix `connector` shadowing to fix no-tls build (#1334) * Fix no-tls build for `Client` excessive shadowing to avoid `connector` being an undefined var for no-tls build. for #1333 Signed-off-by: clux * feature test Signed-off-by: clux * limit TlsRequired error to no-tls when scheme is HTTPS spotted in upstream discussion Signed-off-by: clux * fix comment Signed-off-by: clux --------- Signed-off-by: clux --- .github/workflows/ci.yml | 4 ++++ kube-client/src/client/builder.rs | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 16dc65821..c28eeb294 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,6 +47,10 @@ jobs: - name: Build workspace run: cargo build + - name: Build no-tls + run: cargo build -p kube --no-default-features --features=client + if: matrix.os == 'ubuntu-latest' # only linux tests all feature combinations + # Workspace unit tests with various feature sets - name: Run workspace unit tests (no default features) run: cargo test --workspace --lib --no-default-features -j6 diff --git a/kube-client/src/client/builder.rs b/kube-client/src/client/builder.rs index 6c0b4cd31..e1ae4871c 100644 --- a/kube-client/src/client/builder.rs +++ b/kube-client/src/client/builder.rs @@ -94,7 +94,7 @@ impl TryFrom for ClientBuilder { /// Helper function for implementation of [`TryFrom`] for [`ClientBuilder`]. /// Ignores [`Config::proxy_url`], which at this point is already handled. -fn make_generic_builder(base_connector: H, config: Config) -> Result, Error> +fn make_generic_builder(connector: H, config: Config) -> Result, Error> where H: 'static + Clone + Send + Sync + Service, H::Response: 'static + Connection + AsyncRead + AsyncWrite + Send + Unpin, @@ -111,12 +111,12 @@ where // Create a custom client to use something else. // If TLS features are not enabled, http connector will be used. #[cfg(feature = "rustls-tls")] - let connector = config.rustls_https_connector_with_connector(base_connector)?; + let connector = config.rustls_https_connector_with_connector(connector)?; #[cfg(all(not(feature = "rustls-tls"), feature = "openssl-tls"))] - let connector = config.openssl_https_connector_with_connector(base_connector)?; + let connector = config.openssl_https_connector_with_connector(connector)?; #[cfg(all(not(feature = "rustls-tls"), not(feature = "openssl-tls")))] - if auth_layer.is_none() || config.cluster_url.scheme() == Some(&http::uri::Scheme::HTTPS) { - // no tls stack situation only works on anonymous auth with http scheme + if config.cluster_url.scheme() == Some(&http::uri::Scheme::HTTPS) { + // no tls stack situation only works with http scheme return Err(Error::TlsRequired); }