pub fn incluster_config() -> Result<Configuration> {
    let server = incluster_config::kube_server().ok_or_else(||
        Error::KubeConfig(format!(
            "Unable to load incluster config, {} and {} must be defined",
            incluster_config::SERVICE_HOSTENV,
            incluster_config::SERVICE_PORTENV
    )))?;

    let cert = incluster_config::load_cert()?;

    let token = incluster_config::load_token()
        .map_err(|e| Error::KubeConfig(format!("Unable to load in cluster token: {}", e)))?;

    let default_ns = incluster_config::load_default_ns().map_err(|e| Error::KubeConfig(
        format!("Unable to load incluster default namespace: {}", e),
    ))?;

    let mut headers = header::HeaderMap::new();
    headers.insert(
        header::AUTHORIZATION,
        header::HeaderValue::from_str(&format!("Bearer {}", token))
            .map_err(|e| Error::KubeConfig(format!("Invalid bearer token: {}", e)))?,
    );

    let client_builder = Client::builder()
        .add_root_certificate(cert)
        .default_headers(headers);

    Ok(Configuration::with_default_ns(
        server,
        client_builder.build()
            .map_err(|e| Error::KubeConfig(format!("Unable to build client: {}", e)))?,
        default_ns,
    ))
}
/// Returns a config which is used by clients within pods on kubernetes.
///
/// It will return an error if called from out of kubernetes cluster.
Returns a config which is used by clients within pods on kubernetes.
It will return an error if called from out of kubernetes cluster.
Returns a config which is used by clients within pods on kubernetes . It will return an error if called from out of kubernetes cluster .
pub fn incluster_config() -> Result<Configuration> {
    let server = incluster_config::kube_server().ok_or_else(||
        Error::KubeConfig(format!(
            "Unable to load incluster config, {} and {} must be defined",
            incluster_config::SERVICE_HOSTENV,
            incluster_config::SERVICE_PORTENV
    )))?;
    let cert = incluster_config::load_cert()?;
    let token = incluster_config::load_token()
        .map_err(|e| Error::KubeConfig(format!("Unable to load in cluster token: {}", e)))?;
    let default_ns = incluster_config::load_default_ns().map_err(|e| Error::KubeConfig(
        format!("Unable to load incluster default namespace: {}", e),
    ))?;
    let mut headers = header::HeaderMap::new();
    headers.insert(
        header::AUTHORIZATION,
        header::HeaderValue::from_str(&format!("Bearer {}", token))
            .map_err(|e| Error::KubeConfig(format!("Invalid bearer token: {}", e)))?,
    );
    let client_builder = Client::builder()
        .add_root_certificate(cert)
        .default_headers(headers);
    Ok(Configuration::with_default_ns(
        server,
        client_builder.build()
            .map_err(|e| Error::KubeConfig(format!("Unable to build client: {}", e)))?,
        default_ns,
    ))
}
pub fn incluster_config ( ) -> Result < Configuration > { let server = incluster_config :: kube_server ( ) . ok_or_else ( | | Error :: KubeConfig ( format ! ( " " incluster_config SERVICE_HOSTENV incluster_config SERVICE_PORTENV ) ) ) ? ; let cert = incluster_config :: load_cert ( ) ? ; let token = incluster_config :: load_token ( ) . map_err ( | e | Error :: KubeConfig ( format ! ( " " e ) ) ) ? ; let default_ns = incluster_config :: load_default_ns ( ) . map_err ( | e | Error :: KubeConfig ( format ! ( " " e ) , ) ) ? ; let mut headers = header :: HeaderMap :: new ( ) ; headers . insert ( header :: AUTHORIZATION , header :: HeaderValue :: from_str ( & format ! ( " " token ) ) . map_err ( | e | Error :: KubeConfig ( format ! ( " " e ) ) ) ? , ) ; let client_builder = Client :: builder ( ) . add_root_certificate ( cert ) . default_headers ( headers ) ; Ok ( Configuration :: with_default_ns ( server , client_builder . build ( ) . map_err ( | e | Error :: KubeConfig ( format ! ( " " e ) ) ) ? , default_ns , ) ) }
Returns a config which is used by clients within pods on kubernetes.
Returns a config which is used by clients within pods on kubernetes .