feat: add test hook button for notification hooks - #1323
Open
caco3 wants to merge 2 commits into
Open
Conversation
caco3
marked this pull request as ready for review
July 24, 2026 21:37
Contributor
Author
|
There are many open issues which will benefit from this feature: |
| } | ||
|
|
||
| ctx = orchestratorlogging.ContextWithWriter(ctx, io.Discard) | ||
| if err := handler.Execute(ctx, hook, vars, &testHookRunner{}, event); err != nil { |
Owner
There was a problem hiding this comment.
I think it'd be fine to use a real [taskrunnerimpl](https://github.com/garethgeorge/backrest/blob/main/internal/orchestrator/taskrunnerimpl.go] here.
Let's introduce a ReadOnlyTaskRunnerDecorator in that same file which wraps a task runner and no-ops methods that mutate state
- CreateOperation
- DeleteOperation
- ScheduleTask
- LogrefWriter
wdyt?
Owner
|
Thanks for the interest in contributing this -- agree this is much wanted and its a great contribution! I think it'd actually be reasonable to inject a real but decorated taskrunnerimpl here and decorate it. |
Contributor
Author
|
@garethgeorge Good call — using a real task runner is much cleaner. I added the What changed
|
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.
Adds a Test button to every hook form so users can immediately verify a hook (e.g. Telegram, Discord, Slack) with a test message before saving:
What's changed
TestHookRPC to the backend.TestHookexecutes the provided hook with syntheticHookVarsand returns an error if the hook fails.TestHookuses a realTaskRunnerviaorchestrator.NewReadOnlyTaskRunner. AreadOnlyTaskRunnerdecorator wraps the real runner and no-ops state-mutating methods (CreateOperation,UpdateOperation,DeleteOperation,ScheduleTask,LogrefWriter) so the test cannot create operations, schedule tasks, or write log refs.testHook, and shows a success or error toast.Technical details
proto/v1/service.proto: adds theTestHookRPC.gen/go/v1/service.*.go: generated client/server code for the new RPC.internal/orchestrator/taskrunnerimpl.go: addsreadOnlyTaskRunnerand theNewReadOnlyTaskRunner(orchestrator, task)constructor.internal/api/backresthandler.go: implementsTestHookby creating a minimaltasks.GenericOneoffTaskand running the hook throughorchestrator.NewReadOnlyTaskRunner.Notes