swarm-controller: wire the config-PR webhook, not just the poll
This commit is contained in:
parent
66c494697f
commit
f3e42c93b4
3 changed files with 163 additions and 25 deletions
|
|
@ -311,10 +311,11 @@ pub(super) fn verify(
|
|||
|
||||
/// POST `/webhook/forge/{kind}` — a swarm-wide Forgejo delivery.
|
||||
///
|
||||
/// Verifies the HMAC over the raw body. Nothing consumes the delivery yet;
|
||||
/// once the swarm→hive channel lands, this daemon **parses** it and emits a
|
||||
/// semantic message (*knowledge repo changed*, *deploy agent X at rev Y*) to
|
||||
/// the hives that need it — see the module docs.
|
||||
/// Verifies the HMAC over the raw body, then acts per `kind`: a `Knowledge`
|
||||
/// delivery announces the change to every hive (see
|
||||
/// [`announce_knowledge_change`]); a `ConfigPr` delivery updates
|
||||
/// `crate::config_pr::ConfigPrCache` immediately (see that module's doc
|
||||
/// comment for why both this and a periodic poll write the same cache).
|
||||
///
|
||||
/// Returns 200 on an accepted delivery so Forgejo does not retry. A refused
|
||||
/// one answers 401 (bad signature) or 503 (this daemon has no secret), and
|
||||
|
|
@ -367,14 +368,13 @@ pub(super) async fn post_webhook_forge(
|
|||
"webhook: verified delivery"
|
||||
);
|
||||
|
||||
// Only the knowledge delivery is acted on. Deploy coordination is a
|
||||
// separate concern with its own issue — a hive does not want to hear that a
|
||||
// config PR was opened, it wants to be told when to rebuild from main, and
|
||||
// that is a decision the controller makes after a merge rather than a relay
|
||||
// of this delivery. Written as a condition rather than a match arm holding
|
||||
// an empty body, which would claim this is where that path is handled.
|
||||
if kind == DeliveryKind::Knowledge {
|
||||
announce_knowledge_change(&state).await;
|
||||
match kind {
|
||||
DeliveryKind::Knowledge => announce_knowledge_change(&state).await,
|
||||
DeliveryKind::ConfigPr => {
|
||||
if let Some(cache) = state.config_prs.as_ref() {
|
||||
cache.apply_webhook_delivery(&body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(StatusCode::OK, "ok").into_response()
|
||||
|
|
|
|||
Loading…
Reference in a new issue