Skip to content

Support for NO_PROXY #1203

@goenning

Description

@goenning

Would you like to work on this feature?

yes

What problem are you trying to solve?

kube-rs currently supports the HTTP_PROXY (and all its variants) environment variable, but not the NO_PROXY var.

pub fn proxy_url(&self) -> Result<Option<http::Uri>, KubeconfigError> {
let nonempty = |o: Option<String>| o.filter(|s| !s.is_empty());
if let Some(proxy) = nonempty(self.cluster.proxy_url.clone())
.or_else(|| nonempty(std::env::var("HTTP_PROXY").ok()))
.or_else(|| nonempty(std::env::var("http_proxy").ok()))
.or_else(|| nonempty(std::env::var("HTTPS_PROXY").ok()))
.or_else(|| nonempty(std::env::var("https_proxy").ok()))
{
Ok(Some(
proxy
.parse::<http::Uri>()
.map_err(KubeconfigError::ParseProxyUrl)?,
))
} else {
Ok(None)
}
}

The NO_PROXY var is not standardised, but it's supported by Go and I think we could follow with similar support in here.

Describe the solution you'd like

change the proxy_url fn so that if NO_PROXY is set and the content matches the cluster.server url, return None, otherwise continue as usual.

The matching impl could be similar to seanmonstar/reqwest#877

Describe alternatives you've considered

None

Documentation, Adoption, Migration Strategy

N/A

Target crate for feature

kube-client

Metadata

Metadata

Assignees

No one assigned

    Labels

    clientkube Client relatedhelp wantedNot immediately prioritised, please help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions