Skip to content

Commit 72a2b22

Browse files
authored
Merge pull request #9702 from Turbo87/team-repo-crate
Extract `crates_io_team_repo` crate
2 parents 2fa9f9c + b16b5a3 commit 72a2b22

File tree

14 files changed

+54
-13
lines changed

14 files changed

+54
-13
lines changed

Cargo.lock

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ crates_io_github = { path = "crates/crates_io_github" }
5555
crates_io_index = { path = "crates/crates_io_index" }
5656
crates_io_markdown = { path = "crates/crates_io_markdown" }
5757
crates_io_tarball = { path = "crates/crates_io_tarball" }
58+
crates_io_team_repo = { path = "crates/crates_io_team_repo" }
5859
crates_io_worker = { path = "crates/crates_io_worker" }
5960
csv = "=1.3.0"
6061
chrono = { version = "=0.4.38", default-features = false, features = ["serde"] }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "crates_io_team_repo"
3+
version = "0.0.0"
4+
license = "MIT OR Apache-2.0"
5+
edition = "2021"
6+
7+
[lints]
8+
workspace = true
9+
10+
[dependencies]
11+
anyhow = "=1.0.90"
12+
async-trait = "=0.1.83"
13+
mockall = "=0.13.0"
14+
reqwest = { version = "=0.12.8", features = ["gzip", "json"] }
15+
serde = { version = "=1.0.210", features = ["derive"] }
16+
17+
[dev-dependencies]
18+
tokio = { version = "=1.40.0", features = ["macros", "rt-multi-thread"] }
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
use crates_io_team_repo::{TeamRepo, TeamRepoImpl};
2+
3+
#[tokio::main]
4+
async fn main() -> anyhow::Result<()> {
5+
let team_repo = TeamRepoImpl::default();
6+
let permission = team_repo.get_permission("crates_io_admin").await?;
7+
println!("{permission:#?}");
8+
Ok(())
9+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// Certificate from <https://letsencrypt.org/certificates/>.
2+
pub const ISRG_ROOT_X1: &[u8] = include_bytes!("./isrg-root-x1.pem");
3+
4+
/// Certificate from <https://letsencrypt.org/certificates/>.
5+
pub const ISRG_ROOT_X2: &[u8] = include_bytes!("./isrg-root-x2.pem");
File renamed without changes.
File renamed without changes.

src/team_repo.rs renamed to crates/crates_io_team_repo/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
//! purposes. The [TeamRepoImpl] struct is the actual implementation of
66
//! the trait.
77
8-
use crate::certs;
98
use async_trait::async_trait;
109
use mockall::automock;
1110
use reqwest::{Certificate, Client};
11+
use serde::Deserialize;
12+
13+
mod certs;
1214

1315
#[automock]
1416
#[async_trait]
@@ -68,7 +70,7 @@ impl TeamRepo for TeamRepoImpl {
6870

6971
#[cfg(test)]
7072
mod tests {
71-
use crate::team_repo::build_client;
73+
use crate::build_client;
7274

7375
/// This test is here to make sure that the client is built
7476
/// correctly without panicking.

src/bin/background-worker.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ use crates_io::cloudfront::CloudFront;
1818
use crates_io::db::make_manager_config;
1919
use crates_io::fastly::Fastly;
2020
use crates_io::storage::Storage;
21-
use crates_io::team_repo::TeamRepoImpl;
2221
use crates_io::worker::{Environment, RunnerExt};
2322
use crates_io::{config, Emails};
2423
use crates_io::{db, ssh};
2524
use crates_io_env_vars::var;
2625
use crates_io_index::RepositoryConfig;
26+
use crates_io_team_repo::TeamRepoImpl;
2727
use crates_io_worker::Runner;
2828
use diesel_async::pooled_connection::deadpool::Pool;
2929
use diesel_async::pooled_connection::AsyncDieselConnectionManager;

src/certs/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
1-
/// Certificate from <https://letsencrypt.org/certificates/>.
2-
pub const ISRG_ROOT_X1: &[u8] = include_bytes!("./isrg-root-x1.pem");
3-
4-
/// Certificate from <https://letsencrypt.org/certificates/>.
5-
pub const ISRG_ROOT_X2: &[u8] = include_bytes!("./isrg-root-x2.pem");
6-
71
/// crates.io team certificate from <https://crunchybridge.com/>.
82
pub const CRUNCHY: &[u8] = include_bytes!("./crunchy.pem");

0 commit comments

Comments
 (0)