Skip to content

cli: declare custom run flags on the lint and test subcommands - #531

Merged
Leward merged 1 commit into
mainfrom
eng-1270-lint-test-custom-run-flags
Oct 20, 2026
Merged

Leward merged 1 commit into
mainfrom
eng-1270-lint-test-custom-run-flags

Conversation

@Leward

@Leward Leward commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Warning

After this change, the root-level form of a custom flag stops working for lint and test in Redpanda Connect (connect --rpc-plugins plugin.yaml lint cfg.yaml).
Connect must not pick up this release without the Connect change that reads both levels.

Summary

lint and test now declare opts.CustomRunFlags, as run and streams already do through common.RunFlags.
Both actions already call opts.CustomRunExtractFn(c), so the custom flags are now settable after the subcommand name.

 lintCliCommand / test.CliCommand
   flags = [own flags...]
   flags = append(flags, common.EnvFileAndTemplateFlags(...)...)
+  flags = append(flags, opts.CustomRunFlags...)

Evidence

Unit test. TestRunCLICustomFlags (public/service/service_test.go) is now a table over run, lint and test:

meow <cmd> --meow foobar foo.yaml  ->  extract fn sees ["foobar"]
  • Before: run passes. lint and test fail with flag provided but not defined: -meow.
  • After: all three pass.

End-to-end. Connect main with the catshout test plugin, built against benthos v4.83.0 (before) and this branch (after).
test gives the same results as lint.

Command Before After
connect lint --rpc-plugins plugin.yaml cfg.yaml ❌ flag provided but not defined ✅
connect --rpc-plugins plugin.yaml lint cfg.yaml ✅ ❌ unable to infer processor type
connect --rpc-plugins plugin.yaml run cfg.yaml ❌ unable to infer processor type ❌ (no change)

Merge Danger

Door: two-way

A revert of two lines restores the old behaviour.

Blast Radius: downstream-CLIs

  • When a subcommand declares a flag, urfave/cli v2 reads the subcommand value only, also when the flag is not set there. It does not fall back to the root value. Connect gets an empty rpc-plugins list and does not load the plugin.
  • This applies to all Connect custom flags (--secrets, --redpanda-license, --chroot, telemetry). run and streams already behave like this today (last table row).
  • lint --help and test --help now list the custom flags of downstream tools.
  • No effect on builds that do not set CLIOptCustomRunFlags.

Ref: ENG-1270

@claude

This comment has been minimized.

@claude

This comment has been minimized.

@Leward
Leward force-pushed the eng-1270-lint-test-custom-run-flags branch from ca77e80 to 105a460 Compare October 16, 2026 18:56
@claude

This comment has been minimized.

@Leward
Leward force-pushed the eng-1270-lint-test-custom-run-flags branch from 105a460 to dd2d9b5 Compare October 16, 2026 18:58
@claude

This comment has been minimized.

@claude

This comment was marked as outdated.

The lint and test subcommands already call CustomRunExtractFn, but they did
not declare CustomRunFlags. Thus a flag such as --rpc-plugins was only
settable before the subcommand name.

Extend TestRunCLICustomFlags to a table over run, lint and test. Use
RunCLIToCode, because RunCLI calls os.Exit on a non-zero exit code.

Ref: ENG-1270
@Leward
Leward force-pushed the eng-1270-lint-test-custom-run-flags branch from dd2d9b5 to 6ba7ffa Compare October 19, 2026 18:07
@Leward Leward changed the title cli: accept custom run flags after the lint and test subcommands cli: declare custom run flags on the lint and test subcommands Oct 19, 2026
@claude

claude Bot commented Oct 19, 2026

Copy link
Copy Markdown

Commits
LGTM

Review
Adds CustomRunFlags to the lint and test subcommand flag sets so custom flags (e.g. --rpc-plugins) can be passed after the subcommand name. Both subcommands already call CustomRunExtractFn, so the extraction path is now consistent with run/streams. TestRunCLICustomFlags is extended into a table-driven test covering run, lint and test, using RunCLIToCode to avoid os.Exit.

LGTM

@Leward
Leward merged commit 8f4d256 into main Oct 20, 2026
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants