MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / build_api_client

Function build_api_client

src/cli/mod.rs:309–324  ·  view source on GitHub ↗

Build the api client for this invocation, resolving the auth token from the most specific source available. This is the single source of truth for token resolution; the result lives on the returned client and every downstream consumer (GraphQL queries, upload `Authorization` header, executor env injection) reads it from there. Priority (most specific first): 1. `--token` / `CODSPEED_TOKEN`

(cli: &Cli, config: &CodSpeedConfig)

Source from the content-addressed store, hash-verified

307/// 2. `--oauth-token` / `CODSPEED_OAUTH_TOKEN` and the persisted CLI
308/// token from the selected profile.
309fn build_api_client(cli: &Cli, config: &CodSpeedConfig) -> CodSpeedAPIClient {
310 let run_token = match &cli.command {
311 Commands::Run(args) => args.shared.token.clone(),
312 Commands::Exec(args) => args.shared.token.clone(),
313 _ => None,
314 };
315 let authentication = match run_token {
316 Some(token) => Authentication::RunToken(token),
317 None => config
318 .auth
319 .token
320 .clone()
321 .map_or(Authentication::Tokenless, Authentication::CliLogin),
322 };
323 CodSpeedAPIClient::new(authentication, config.api_url.clone())
324}

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected