fix: stream plugin RPC stdout live and preserve Traefik templates#63
Merged
Merged
Conversation
eea16ad to
0fc21e4
Compare
This addresses two unrelated paper cuts in the plugin RPC path and the
Traefik bot-mitigation config rewriter.
Plugin RPC reserves process stdout for the JSON response envelope, so
long-running commands like `sitectl create` produced no visible progress
until the plugin exited. This adds an opt-in `LiveStdout` execution option
(driven by the `SITECTL_RPC_LIVE_STDOUT=1` env var) that mirrors command
stdout to the plugin process stderr while still capturing it into
`RPCResponse.Output`. The host enables it for `create` so progress streams
live; the buffered output is then suppressed to avoid duplicate printing.
- `cmd/create.go`: enable LiveStdout and skip re-printing captured output
- `pkg/plugin/sdk.go`: add `CommandExecOptions.LiveStdout`, plumb the env
var, and route the plugin stderr sink when either live flag is set
- `pkg/plugin/rpc_command.go`: mirror command stdout to stderr in the
plugin when `SITECTL_RPC_LIVE_STDOUT=1`
The bot-mitigation rewriter loaded the router config through a YAML parser
to inject middleware. Traefik router files embed Go template scalars such
as `{{ env "DOMAIN" }}`, which are not valid bare YAML and broke the load.
This quotes unquoted `{{ ... }}` scalar values before parsing and leaves
already-quoted values untouched, so the templates survive the round-trip.
- `pkg/services/traefik/bot_mitigation.go`: add `quoteTraefikTemplateScalars`
/ `singleQuoteYAMLScalar` and run them before `LoadYAMLDocument`
0fc21e4 to
20e60a6
Compare
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.
This addresses two unrelated paper cuts in the plugin RPC path and the Traefik bot-mitigation config rewriter.
Live plugin stdout
Plugin RPC reserves process stdout for the JSON response envelope, so long-running commands like
sitectl createproduced no visible progress until the plugin exited. This adds an opt-inLiveStdoutexecution option (driven by theSITECTL_RPC_LIVE_STDOUT=1env var) that mirrors command stdout to the plugin process stderr while still capturing it intoRPCResponse.Output. The host enables it forcreateso progress streams live; the buffered output is then suppressed to avoid duplicate printing.cmd/create.go: enable LiveStdout and skip re-printing captured outputpkg/plugin/sdk.go: addCommandExecOptions.LiveStdout, plumb the env var, and route the plugin stderr sink when either live flag is setpkg/plugin/rpc_command.go: mirror command stdout to stderr in the plugin whenSITECTL_RPC_LIVE_STDOUT=1Traefik template-safe YAML rewrite
The bot-mitigation rewriter loaded the router config through a YAML parser to inject middleware. Traefik router files embed Go template scalars such as
{{ env "DOMAIN" }}, which are not valid bare YAML and broke the load. This quotes unquoted{{ ... }}scalar values before parsing and leaves already-quoted values untouched, so the templates survive the round-trip.pkg/services/traefik/bot_mitigation.go: addquoteTraefikTemplateScalars/singleQuoteYAMLScalarand run them beforeLoadYAMLDocument