feat(controller): git push webhook for immediate reconcile (homelab B3)#136
Merged
Conversation
Adds a push-triggered reconcile so a git push converges the controller
immediately instead of waiting for the pull interval.
- server.GitOpsWebhook: a POST-only HTTP endpoint that verifies GitHub's
HMAC-SHA256 X-Hub-Signature-256 header (constant-time compare) against a
configured secret, then fires an async pull+reconcile and returns 202. An
empty secret disables verification (trusted-network mode). Threaded through
the HTTP gateway exactly like the OIDC handler (nil = not mounted).
- Repo.PullAndReconcile: extracted the ticker's pull + HEAD-advance-detection +
onChange body into a shared method, so the webhook and the periodic pull take
the identical path (StartPeriodicPull now delegates to it).
- Config: manifests.gitops.pull.webhook.{enabled, secret, path} (default path
/gitops/webhook).
Completes Area B (git-as-source): remote commits pull+reconcile (B1), removed
files prune with guards (B2), a push webhook converges immediately (B3). All
opt-in.
Tests: valid/bad/missing signature, non-POST, unsigned mode, and route
mounting (custom path mounts; nil/trigger-less handler does not).
Target B3 of Homelab-completion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Roadmap target B3, completing Area B (git-as-source / the DriftlessAF loop). Adds a push-triggered reconcile so a git push converges the controller immediately instead of waiting for the pull interval.
What
server.GitOpsWebhook— a POST-only HTTP endpoint that verifies GitHub's HMAC-SHA256X-Hub-Signature-256header (constant-time compare) against a configured secret, then fires an async pull+reconcile and returns202 Accepted(webhooks want a fast ack). An empty secret disables verification (trusted-network mode). Threaded through the HTTP gateway exactly like the OIDC handler (nil= not mounted).Repo.PullAndReconcile— extracted the ticker's pull + HEAD-advance detection +onChangeinto a shared method, so the webhook and the periodic pull take the identical path (StartPeriodicPullnow delegates to it).manifests.gitops.pull.webhook.{enabled, secret, path}(default path/gitops/webhook).Point a GitHub push webhook (content-type JSON, secret set) at
https://<controller>/gitops/webhookand pushes reconcile in ~seconds.Area B complete (B1–B3)
git is now a first-class source, not just a sink:
All opt-in; defaults unchanged. (PR-based change proposal is intentionally left to Argo per the design doc — openctl reconciles the infra-coupled layer it owns.)
Tests
Valid / bad / missing signature, non-POST rejection, unsigned-mode accept, and route mounting (custom path mounts; a nil / trigger-less handler does not). Gateway signature change rippled to one test +
ServeHTTPGateway+ main.go.