Webhook Middleware Phase 4: CLI configuration support#4410
Draft
Sanskarzz wants to merge 3 commits intostacklok:mainfrom
Draft
Webhook Middleware Phase 4: CLI configuration support#4410Sanskarzz wants to merge 3 commits intostacklok:mainfrom
Sanskarzz wants to merge 3 commits intostacklok:mainfrom
Conversation
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Signed-off-by: Sanskarzz <sanskar.gur@gmail.com>
Contributor
There was a problem hiding this comment.
Large PR Detected
This PR exceeds 1000 lines of changes and requires justification before it can be reviewed.
How to unblock this PR:
Add a section to your PR description with the following format:
## Large PR Justification
[Explain why this PR must be large, such as:]
- Generated code that cannot be split
- Large refactoring that must be atomic
- Multiple related changes that would break if separated
- Migration or data transformationAlternative:
Consider splitting this PR into smaller, focused changes (< 1000 lines each) for easier review and reduced risk.
See our Contributing Guidelines for more details.
This review will be automatically dismissed once you add the justification section.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4410 +/- ##
==========================================
+ Coverage 69.53% 69.58% +0.04%
==========================================
Files 485 490 +5
Lines 49879 50212 +333
==========================================
+ Hits 34684 34940 +256
- Misses 12516 12575 +59
- Partials 2679 2697 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
[WIP] Depends on the merge of Phase 3 PR
Summary
This PR implements Phase 4 of the Dynamic Webhook Middleware RFC (THV-0017), introducing CLI configuration support for passing validating and mutating webhooks to
thv run.Users can now define their webhook pipelines in YAML or JSON files and inject them into the ToolHive runner at startup using the
--webhook-configflag.Fixes #3400
Key Changes
pkg/webhook/config.goFileConfigstruct to unmarshal both YAML and JSON webhook configuration files (auto-detected via file extension).MergeConfigsto support combining multiple configuration files. Files passed later in the arguments take precedence for webhooks with the samename(last-writer-wins deduplication).ValidateConfigto aggregatewh.Validate()errors across all provided mutating and validating webhook definitions to fail fast at CLI startup.cmd/thv/app/run_flags.goWebhookConfigs []stringproperty toRunFlags.--webhook-configflag which can be specified multiple times.loadAndMergeWebhookConfigshelper to parse and process the files into a singlewebhook.FileConfig.pkg/runner/config_builder.goWithValidatingWebhooksandWithMutatingWebhooksbuilder functions to inject parsed webhooks intoRunConfig.WithMiddlewareFromFlagsto actively instantiate and appendaddMutatingWebhookMiddlewareandaddValidatingWebhookMiddlewaredirectly to thethvrunner chain (matching the existing Operator behavior).Testing
yamlandjson), parsing errors, file aggregation, deduplication sorting, and granular validation constraints insidepkg/webhook/config_test.go.task lintand passingtask test-coveragerequirements../thv run fetch --webhook-config webhook-config/webhooks.yaml --debugtargets, confirmingauth -> mcp-parser -> mutating-webhook -> validating-webhookproxy application inside.thv logs.webhook-config/webhooks.yamlType of change
Test plan
task test)task test-e2e)task lint-fix)