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

Function build_api_client

src/cli/mod.rs:244–255  ·  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

242/// 2. `--oauth-token` / `CODSPEED_OAUTH_TOKEN` and the persisted CLI
243/// token from the selected profile.
244fn build_api_client(cli: &Cli, config: &CodSpeedConfig) -> CodSpeedAPIClient {
245 let explicit = match &cli.command {
246 Commands::Run(args) => args.shared.token.clone(),
247 Commands::Exec(args) => args.shared.token.clone(),
248 _ => None,
249 };
250 let token = match explicit {
251 Some(token) => Some(token),
252 None => config.auth.token.clone(),
253 };
254 CodSpeedAPIClient::new(token, config.api_url.clone())
255}

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected