async fn call_pinniped_exchange_tmc(
    authorization: &str,
    k8s_api_server_url: &str,
    k8s_api_ca_cert_data: &[u8],
) -> Result<TokenCredentialRequestTMC> {
    let pinniped_namespace = env::var(DEFAULT_PINNIPED_NAMESPACE)?;
    let client = get_client_config(
        k8s_api_server_url,
        k8s_api_ca_cert_data,
        pinniped_namespace.clone(),
    )?;
    let auth_token = match authorization.to_string().strip_prefix("Bearer ") {
        Some(a) => a.to_string(),
        None => authorization.to_string(),
    };
    let token_creds: Api<TokenCredentialRequestTMC> = Api::all(client.clone());
    let cred_request = TokenCredentialRequestTMC::new(
        "",
        TokenCredentialRequestTMCSpec {
            token: Some(auth_token),
            authenticator: corev1::TypedLocalObjectReference {
                name: env::var(DEFAULT_PINNIPED_AUTHENTICATOR_NAME).with_context(|| {
                    format!("error retrieving {}", DEFAULT_PINNIPED_AUTHENTICATOR_NAME)
                })?,
                kind: env::var(DEFAULT_PINNIPED_AUTHENTICATOR_TYPE).with_context(|| {
                    format!("error retrieving {}", DEFAULT_PINNIPED_AUTHENTICATOR_TYPE)
                })?,
                api_group: Some(get_pinniped_authenticator_api_group().into()),
            },
        },
    );

    debug!("{}", serde_json::to_string(&cred_request).unwrap());
    match token_creds
        .create(&PostParams::default(), &cred_request)
        .await
    {
        Ok(o) => Ok(o),
        Err(e) => Err(anyhow::anyhow!(
            "err creating token exchange: {:#?}\n{}",
            serde_json::to_string(&cred_request).unwrap(),
            e
        )),
    }
}
/// call_pinniped_exchange returns the resulting TokenCredentialRequest with Status after requesting a token credential exchange.
// TODO(agamez): remove this duplicated code and use a generic dynamic approach when possible.
// see PR comments: https://github.com/kubeapps/kubeapps/pull/2515
call_pinniped_exchange returns the resulting TokenCredentialRequest with Status after requesting a token credential exchange.
TODO(agamez): remove this duplicated code and use a generic dynamic approach when possible.
call_pinniped_exchange returns the resulting TokenCredentialRequest with Status after requesting a token credential exchange . TODO ( agamez ) : remove this duplicated code and use a generic dynamic approach when possible .
async fn call_pinniped_exchange_tmc(
    authorization: &str,
    k8s_api_server_url: &str,
    k8s_api_ca_cert_data: &[u8],
) -> Result<TokenCredentialRequestTMC> {
    let pinniped_namespace = env::var(DEFAULT_PINNIPED_NAMESPACE)?;
    let client = get_client_config(
        k8s_api_server_url,
        k8s_api_ca_cert_data,
        pinniped_namespace.clone(),
    )?;
    let auth_token = match authorization.to_string().strip_prefix("Bearer ") {
        Some(a) => a.to_string(),
        None => authorization.to_string(),
    };
    let token_creds: Api<TokenCredentialRequestTMC> = Api::all(client.clone());
    let cred_request = TokenCredentialRequestTMC::new(
        "",
        TokenCredentialRequestTMCSpec {
            token: Some(auth_token),
            authenticator: corev1::TypedLocalObjectReference {
                name: env::var(DEFAULT_PINNIPED_AUTHENTICATOR_NAME).with_context(|| {
                    format!("error retrieving {}", DEFAULT_PINNIPED_AUTHENTICATOR_NAME)
                })?,
                kind: env::var(DEFAULT_PINNIPED_AUTHENTICATOR_TYPE).with_context(|| {
                    format!("error retrieving {}", DEFAULT_PINNIPED_AUTHENTICATOR_TYPE)
                })?,
                api_group: Some(get_pinniped_authenticator_api_group().into()),
            },
        },
    );
    debug!("{}", serde_json::to_string(&cred_request).unwrap());
    match token_creds
        .create(&PostParams::default(), &cred_request)
        .await
    {
        Ok(o) => Ok(o),
        Err(e) => Err(anyhow::anyhow!(
            "err creating token exchange: {:#?}\n{}",
            serde_json::to_string(&cred_request).unwrap(),
            e
        )),
    }
}
async fn call_pinniped_exchange_tmc ( authorization : & str , k8s_api_server_url : & str , k8s_api_ca_cert_data : & [ u8 ] , ) -> Result < TokenCredentialRequestTMC > { let pinniped_namespace = env :: var ( DEFAULT_PINNIPED_NAMESPACE ) ? ; let client = get_client_config ( k8s_api_server_url , k8s_api_ca_cert_data , pinniped_namespace . clone ( ) , ) ? ; let auth_token = match authorization . to_string ( ) . strip_prefix ( " " ) { Some ( a ) => a . to_string ( ) , None => authorization . to_string ( ) , } ; let token_creds : Api < TokenCredentialRequestTMC > = Api :: all ( client . clone ( ) ) ; let cred_request = TokenCredentialRequestTMC :: new ( " " , TokenCredentialRequestTMCSpec { token : Some ( auth_token ) , authenticator : corev1 :: TypedLocalObjectReference { name : env :: var ( DEFAULT_PINNIPED_AUTHENTICATOR_NAME ) . with_context ( | | { format ! ( " " DEFAULT_PINNIPED_AUTHENTICATOR_NAME ) } ) ? , kind : env :: var ( DEFAULT_PINNIPED_AUTHENTICATOR_TYPE ) . with_context ( | | { format ! ( " " DEFAULT_PINNIPED_AUTHENTICATOR_TYPE ) } ) ? , api_group : Some ( get_pinniped_authenticator_api_group ( ) . into ( ) ) , } , } , ) ; debug ! ( " " serde_json to_string ( cred_request ) unwrap ( ) ) ; match token_creds . create ( & PostParams :: default ( ) , & cred_request ) . await { Ok ( o ) => Ok ( o ) , Err ( e ) => Err ( anyhow :: anyhow ! ( " \n " serde_json to_string ( cred_request ) unwrap ( ) e ) ) , } }
call_pinniped_exchange returns the resulting TokenCredentialRequest with Status after requesting a token credential exchange.
call_pinniped_exchange returns the resulting TokenCredentialRequest with Status after requesting a token credential exchange .
authorization
&str
k8s_api_server_url
&str
k8s_api_ca_cert_data
&[u8]