swarm-controller, swarm-ci-metrics: build forge clients through forge-client
This commit is contained in:
parent
d54b59df7e
commit
a77131ca3f
1 changed files with 75 additions and 28 deletions
|
|
@ -20,11 +20,12 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use anyhow::{Context, Result, bail};
|
||||
use forge_client::{StaticToken, async_client};
|
||||
use forgejo_api::Forgejo;
|
||||
use forgejo_api::structs::{
|
||||
ChangeFileOperation, ChangeFileOperationOperation, ChangeFilesOptions, CreatePullReviewOptions,
|
||||
Identity, RepoSearchQuery,
|
||||
};
|
||||
use forgejo_api::{Auth, Forgejo};
|
||||
use swarm_secret_client::forge;
|
||||
use swarm_secret_client::review_classifier::forge_token_path;
|
||||
|
||||
|
|
@ -122,7 +123,7 @@ impl Client {
|
|||
.replace_token(&store, LOGIN, TOKEN_NAME, TOKEN_SCOPES, &listed, &path)
|
||||
.await?;
|
||||
|
||||
Forgejo::new(Auth::Token(&credential.value), self.url.clone())
|
||||
async_client(self.url.clone(), &StaticToken::new(&credential.value))
|
||||
.context("building a forge client with the new token")?
|
||||
.repo_search(RepoSearchQuery::default())
|
||||
.await
|
||||
|
|
@ -221,7 +222,7 @@ impl Client {
|
|||
else {
|
||||
bail!("nothing at {path}: the classifier's forge token is not minted yet");
|
||||
};
|
||||
Forgejo::new(Auth::Token(&credential.value), self.url.clone())
|
||||
async_client(self.url.clone(), &StaticToken::new(&credential.value))
|
||||
.context("building a forge client with the classifier's token")
|
||||
}
|
||||
|
||||
|
|
@ -462,7 +463,7 @@ mod tests {
|
|||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
|
||||
let url = url::Url::parse(&format!("http://{}/", listener.local_addr().unwrap())).unwrap();
|
||||
tokio::spawn(async move { axum::serve(listener, app).await });
|
||||
let forge = Forgejo::new(Auth::Token("stub-token"), url).unwrap();
|
||||
let forge = async_client(url, &StaticToken::new("stub-token")).unwrap();
|
||||
let commit = BranchCommit {
|
||||
base: "main".to_owned(),
|
||||
branch: "review-classifier/alice-0a1b2c3d".to_owned(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue