Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81bebf7e17 | ||
|
|
9ed8905a5c | ||
|
|
8cb28459a0 |
@@ -42,9 +42,17 @@ pub(crate) async fn hook(
|
|||||||
debug!("REQ: {:?}", payload);
|
debug!("REQ: {:?}", payload);
|
||||||
match payload {
|
match payload {
|
||||||
HookRequest::Push(webhook_payload) => {
|
HookRequest::Push(webhook_payload) => {
|
||||||
|
let kubernetes_client: kube::Client = kube::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 push_result = handle_push(
|
let push_result = handle_push(
|
||||||
state.gitea,
|
gitea,
|
||||||
state.kubernetes_client,
|
kubernetes_client,
|
||||||
state.allowed_repos.borrow(),
|
state.allowed_repos.borrow(),
|
||||||
webhook_payload,
|
webhook_payload,
|
||||||
)
|
)
|
||||||
@@ -58,16 +66,18 @@ pub(crate) async fn hook(
|
|||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
Err(_) => (
|
Err(_) => (
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
// StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
StatusCode::OK,
|
||||||
Json(HookResponse {
|
Json(HookResponse {
|
||||||
ok: false,
|
ok: false,
|
||||||
message: Some(format!("Failed to handle push event.")),
|
message: Some("Failed to handle push event.".to_string()),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
HookRequest::Unrecognized(payload) => (
|
HookRequest::Unrecognized(payload) => (
|
||||||
StatusCode::BAD_REQUEST,
|
// StatusCode::BAD_REQUEST,
|
||||||
|
StatusCode::OK,
|
||||||
Json(HookResponse {
|
Json(HookResponse {
|
||||||
ok: false,
|
ok: false,
|
||||||
message: Some(format!("unrecognized event type: {payload}")),
|
message: Some(format!("unrecognized event type: {payload}")),
|
||||||
|
|||||||
Reference in New Issue
Block a user