Repository navigation
cli: merge root and subcommand --rpc-plugins values, and add the flag to dry-run - #4976
Conversation
3bb2442 to
387b052
Compare
| return err | ||
| } | ||
|
|
||
| if err := rpcplugin.DiscoverAndRegisterPlugins(service.OSFS(), schema.Environment(), rpcPluginPaths(c)); err != nil { |
There was a problem hiding this comment.
The new dry-run plugin registration has no test in this PR. The description says TestDryRunRPCPlugins covers the flag before and after dry-run, but the test is not in the diff, and no file in the repo defines it. TestRPCPluginPaths only tests the helper on a fake app. It does not check that dry-run defines the flag or registers plugins before it parses the targets.
Please commit the TestDryRunRPCPlugins test the description mentions (skipped in CI like internal/rpcplugin/processor_test.go), or add a test that fails without these lines. The project test patterns say to "Flag changed code lacking tests".
There was a problem hiding this comment.
There was a test but its evidence was weak and has therefore been removed.
… to dry-run The rpc-plugins flag is defined on the root app and on run. urfave/cli reads the value from the subcommand context, so the root value was ignored for `connect --rpc-plugins P run`. Add rpcPluginPaths, which collects the values from each level where the flag is set. The paths are not sorted or deduplicated: a second registration of a plugin name replaces the first one, so the root manifest wins over the subcommand manifest. The dry-run command did not register RPC plugins. Add the flag to dry-run and register the plugins before the targets are checked. Ref: ENG-1270
387b052 to
191f6af
Compare
Important
This PR must be in the same Connect release as the benthos bump that brings in redpanda-data/benthos#531, or in an earlier one.
Without it,
connect --rpc-plugins P lintandconnect --rpc-plugins P teststop loading the plugin.This PR does not depend on redpanda-data/benthos#531, so it can merge first.
Summary
--rpc-pluginsis defined on the root app and onrun(and onlintandtestafter redpanda-data/benthos#531). urfave/cli v2c.StringSlicereturns the value from the first flag set in the lineage that defines the flag, also when it is not set there. Thus the root value is lost when the subcommand also defines the flag.dry-rundid not register RPC plugins at all.The Python plugin README now shows
rpk connect dry-run --rpc-plugins=plugin.yaml connect.yamlfor CI checks.lint --rpc-pluginsis not documented yet. Add it when redpanda-data/benthos#531 is in a Connect release.Evidence
Unit tests.
TestRPCPluginPaths: table over root only, command only, both, none.End-to-end. The same checks as redpanda-data/benthos#531, plus
dry-run, with thecatshouttest plugin. Four builds: Connectmain(bcdefa4) and this branch, each against benthos v4.83.0 and against redpanda-data/benthos#531 (dd2d9b5).main+ v4.83.0main+ #531connect lint --rpc-plugins P cfg.yamlflag provided but not definedflag provided but not definedconnect --rpc-plugins P lint cfg.yamlunable to infer processor typeconnect test --rpc-plugins P cfg.yamlflag provided but not definedflag provided but not definedconnect --rpc-plugins P test cfg.yamlunable to infer processor typeconnect run --rpc-plugins P cfg.yamlconnect --rpc-plugins P run cfg.yamlunable to infer processor typeunable to infer processor typeconnect dry-run --rpc-plugins P cfg.yamlflag provided but not definedflag provided but not definedconnect --rpc-plugins P dry-run cfg.yamlunable to infer processor typeunable to infer processor typerunprintsMEOW! MEOW!andtestprintssucceededwhere they pass.Merge Danger
Door: two-way
Blast Radius: CLI
--rpc-pluginsonly. The other custom flags (--secrets,--redpanda-license,--chroot, telemetry) still read the subcommand value only. With cli: declare custom run flags on the lint and test subcommands benthos#531 that also applies tolintandtest.Ref: ENG-1270