Handle errors in push events.
Some checks failed
semver Build semver has succeeded
format Build format has succeeded
rust-test Build rust-test has failed
clippy Build clippy has failed
build Build build has succeeded

This commit is contained in:
Tom Alexander 2024-09-29 18:24:50 -04:00
parent dd4c20f0a7
commit 753ad6dd05
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -42,21 +42,29 @@ pub(crate) async fn hook(
debug!("REQ: {:?}", payload);
match payload {
HookRequest::Push(webhook_payload) => {
handle_push(
let push_result = handle_push(
state.gitea,
state.kubernetes_client,
state.allowed_repos.borrow(),
webhook_payload,
)
.await
.expect("Failed to handle push event.");
(
StatusCode::OK,
Json(HookResponse {
ok: true,
message: None,
}),
)
.await;
match push_result {
Ok(_) => (
StatusCode::OK,
Json(HookResponse {
ok: true,
message: None,
}),
),
Err(_) => (
StatusCode::INTERNAL_SERVER_ERROR,
Json(HookResponse {
ok: false,
message: Some(format!("Failed to handle push event.")),
}),
),
}
}
HookRequest::Unrecognized(payload) => (
StatusCode::BAD_REQUEST,