Test: Remove the clients from AppState entirely.
This commit is contained in:
parent
e4463fe79d
commit
f3b00c46ea
@ -1,13 +1,7 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use kube::Client;
|
|
||||||
|
|
||||||
use crate::gitea_client::GiteaClient;
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub(crate) struct AppState {
|
pub(crate) struct AppState {
|
||||||
pub(crate) kubernetes_client: Client,
|
|
||||||
pub(crate) gitea: GiteaClient,
|
|
||||||
pub(crate) allowed_repos: Arc<HashSet<String>>,
|
pub(crate) allowed_repos: Arc<HashSet<String>>,
|
||||||
}
|
}
|
||||||
|
10
src/lib.rs
10
src/lib.rs
@ -47,14 +47,6 @@ pub async fn init_tracing() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn launch_server() -> Result<(), Box<dyn std::error::Error>> {
|
pub async fn launch_server() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let kubernetes_client: Client = Client::try_default()
|
|
||||||
.await
|
|
||||||
.expect("Set KUBECONFIG to a valid kubernetes config.");
|
|
||||||
|
|
||||||
let gitea_api_root = std::env::var("WEBHOOK_BRIDGE_API_ROOT")?;
|
|
||||||
let gitea_api_token = std::env::var("WEBHOOK_BRIDGE_OAUTH_TOKEN")?;
|
|
||||||
let gitea = GiteaClient::new(gitea_api_root, gitea_api_token);
|
|
||||||
|
|
||||||
let allowed_repos = std::env::var("WEBHOOK_BRIDGE_REPO_WHITELIST")?;
|
let allowed_repos = std::env::var("WEBHOOK_BRIDGE_REPO_WHITELIST")?;
|
||||||
let allowed_repos: HashSet<_> = allowed_repos
|
let allowed_repos: HashSet<_> = allowed_repos
|
||||||
.split(",")
|
.split(",")
|
||||||
@ -73,8 +65,6 @@ pub async fn launch_server() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
TimeoutLayer::new(Duration::from_secs(600)),
|
TimeoutLayer::new(Duration::from_secs(600)),
|
||||||
))
|
))
|
||||||
.with_state(AppState {
|
.with_state(AppState {
|
||||||
kubernetes_client,
|
|
||||||
gitea,
|
|
||||||
allowed_repos: Arc::new(allowed_repos),
|
allowed_repos: Arc::new(allowed_repos),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user