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

add option to provide headers to send as client #1523

Merged
merged 2 commits into from
Jun 19, 2024
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
2 changes: 1 addition & 1 deletion kube-client/src/client/config_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@
}

fn extra_headers_layer(&self) -> Result<ExtraHeadersLayer> {
let mut headers = Vec::new();
let mut headers = self.headers.clone();
if let Some(impersonate_user) = &self.auth_info.impersonate {
headers.push((
HeaderName::from_static("impersonate-user"),
Expand Down Expand Up @@ -233,7 +233,7 @@
.with_tls_config(rustls_config)
.https_or_http();
if let Some(tsn) = self.tls_server_name.as_ref() {
builder = builder.with_server_name(tsn.clone());

Check warning on line 236 in kube-client/src/client/config_ext.rs

View workflow job for this annotation

GitHub Actions / msrv

use of deprecated method `hyper_rustls::HttpsConnectorBuilder::<hyper_rustls::builderstates::WantsProtocols1>::with_server_name`: use Self::with_server_name_resolver with FixedServerNameResolver instead
}
Ok(builder.enable_http1().wrap_connector(connector))
}
Expand Down
6 changes: 6 additions & 0 deletions kube-client/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//! Unless you have issues, prefer using [`Config::infer`], and pass it to a [`Client`][crate::Client].
use std::{path::PathBuf, time::Duration};

use http::{HeaderName, HeaderValue};
use thiserror::Error;

mod file_config;
Expand Down Expand Up @@ -154,6 +155,8 @@
///
/// If not set, the `cluster_url` is used instead
pub tls_server_name: Option<String>,
/// Headers to pass with every request.
pub headers: Vec<(HeaderName, HeaderValue)>,
clux marked this conversation as resolved.
Show resolved Hide resolved
}

impl Config {
Expand All @@ -174,6 +177,7 @@
auth_info: AuthInfo::default(),
proxy_url: None,
tls_server_name: None,
headers: Vec::new(),

Check warning on line 180 in kube-client/src/config/mod.rs

View check run for this annotation

Codecov / codecov/patch

kube-client/src/config/mod.rs#L180

Added line #L180 was not covered by tests
}
}

Expand Down Expand Up @@ -255,6 +259,7 @@
},
proxy_url: None,
tls_server_name: None,
headers: Vec::new(),

Check warning on line 262 in kube-client/src/config/mod.rs

View check run for this annotation

Codecov / codecov/patch

kube-client/src/config/mod.rs#L262

Added line #L262 was not covered by tests
})
}

Expand Down Expand Up @@ -312,6 +317,7 @@
proxy_url: loader.proxy_url()?,
auth_info: loader.user,
tls_server_name: loader.cluster.tls_server_name,
headers: Vec::new(),
})
}

Expand Down
Loading