pub fn resolve_credentials(
project_root: &Path,
) -> Result<(Option<String>, Option<Credential>), Box<dyn Error>>Expand description
Resolve server URL and credential from multiple sources. Priority: env var > credentials file > project config.toml Returns (server_url, credential).
Only the credentials file can yield a Credential::Keycloak: an env var
or a config.toml api_key is always a tvk_ API key, and an API key is
never treated as refreshable. That asymmetry is the whole contract — CI
and automation stay on the unchanging key path.
§Errors
Fails when the resolved server URL and a credential read from the
credentials file are for different TraceVault instances (see
[server_mismatch_error]). This covers EITHER kind of file-sourced
credential — the distinction that matters is not Keycloak-vs-key but
named-on-this-invocation vs. read-from-the-file. Failing is deliberate
rather than silently dropping the credential: every “Not logged in, run
tracevault login” message downstream would be actively WRONG advice — the
user IS logged in, and logging in again to the same instance would not
change anything.